Android Paths 的静态工厂方法
Artiste is a collection of static methods for creating Path objects initialized with different shapes.
Artiste is on jCenter.
repositories {
jcenter()
}dependencies {
compile 'me.mattlogan.artiste:artiste:4.0.0'
}The Paths class contains the entirety of the public API for this library. It contains three static factory methods, including:
public static Path regularConvexPolygon(int left, int top, int right, int bottom, int numSides, float rotationDegrees)
Creates a regular convex polygon Path.
left — Left boundtop — Top boundright — Right boundbottom — Bottom boundnumSides — Number of sidesrotationDegrees — Degrees to rotate polygonpublic 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.
left — Left boundtop — Top boundright — Right boundbottom — Bottom boundnumPoints — Number of points on stardensity — 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 polygonoutline — True if only the star's outline should be drawn. If false, complete lines will be drawn connecting the star's vertices.public static Path circle(int left, int top, int right, int bottom)
Creates a circle Path.
left — Left boundtop — Top boundright — Right boundbottom — Bottom boundThis 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.
…暂无开放 Issues,或尚未同步最近议题。