百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

Artiste

> 编程语言
开源

Android Paths 的静态工厂方法

192 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Android Paths 的静态工厂方法

Artiste

Artiste is a collection of static methods for creating Path objects initialized with different shapes.

Add as a dependency

Artiste is on jCenter.

groovy
repositories {
    jcenter()
}
groovy
dependencies {
    compile 'me.mattlogan.artiste:artiste:4.0.0'
}

Overview

The Paths class contains the entirety of the public API for this library. It contains three static factory methods, including:

  1. One method for creating a regular convex polygon.
  2. One method for creating a regular star polygon.
  3. One method for creating a circle.

The API

public static Path regularConvexPolygon(int left, int top, int right, int bottom, int numSides, float rotationDegrees)

Creates a regular convex polygon Path.

  • Parameters:
    • left — Left bound
    • top — Top bound
    • right — Right bound
    • bottom — Bottom bound
    • numSides — Number of sides
    • rotationDegrees — Degrees to rotate polygon
  • Returns: A Path corresponding to a regular convex polygon.

public static Path regularStarPolygon(int left, int top, int right, int bottom, int numPoints, int density, float rotationDegrees, boolean outline)

Creates a regular star polygon Path.

  • Parameters:
    • left — Left bound
    • top — Top bound
    • right — Right bound
    • bottom — Bottom bound
    • numPoints — Number of points on star
    • density — Density of the star polygon (the number of vertices, or points, to skip when drawing a line connecting two vertices.)
    • rotationDegrees — Number of degrees to rotate star polygon
    • outline — True if only the star's outline should be drawn. If false, complete lines will be drawn connecting the star's vertices.
  • Returns: A Path corresponding to a regular star polygon.

public static Path circle(int left, int top, int right, int bottom)

Creates a circle Path.

  • Parameters:
    • left — Left bound
    • top — Top bound
    • right — Right bound
    • bottom — Bottom bound
  • Returns: A Path corresponding to a circle.

Tests

This library contains instrumentation tests in the directory /library/src/androidTest/.

It's hard to be 100% sure, even with these tests, that the static factory methods in Paths are returning Path objects initialized with the correct shape. Some of these tests are a bit more implicit -- for example, making sure a pentagon has a larger perimeter than a square. Others just check for known values -- for example, that the perimeter of a square inscribed inside a circle with diameter 100 is 282.84. Finally, some tests check for exceptions that should be thrown for invalid arguments.

In addition to the library module, there's also an example module with a small demo app. This is a quick way to verify that the library works as described for at least a few of the more common shapes you might encounter. The picture at the top of this readme is a cropped screenshot from this example app.

License

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言