| Package | starling.utils |
| Class | public final class Earcut |
| Inheritance | Earcut Object |
| Method | Defined By | ||
|---|---|---|---|
deviation(vertices:Vector.<Number>, holes:Vector.<Number>, dimensions:uint, triangles:Vector.<Number>):Number [static]
Returns the relative difference between the total area of triangles and the area of the input polygon. | Earcut | ||
earcut(vertices:Vector.<Number>, holes:Vector.<uint> = null, dimensions:uint = 2):Vector.<uint> [static]
Triangulate an outline. | Earcut | ||
flatten(data:Vector.<Vector.<Vector.<Number>>>):Object [static]
Transforms multi-dimensional array (e.g. | Earcut | ||
| deviation | () | method |
public static function deviation(vertices:Vector.<Number>, holes:Vector.<Number>, dimensions:uint, triangles:Vector.<Number>):NumberReturns the relative difference between the total area of triangles and the area of the input polygon. 0 means the triangulation is fully correct. Used to verify correctness of triangulation
Parameters
vertices:Vector.<Number> — same as earcut
| |
holes:Vector.<Number> — same as earcut
| |
dimensions:uint — same as earcut
| |
triangles:Vector.<Number> — see return value of earcut
|
Number |
| earcut | () | method |
public static function earcut(vertices:Vector.<Number>, holes:Vector.<uint> = null, dimensions:uint = 2):Vector.<uint>Triangulate an outline.
Parameters
vertices:Vector.<Number> — A flat array of vertice coordinates like [x0,y0, x1,y1, x2,y2, ...].
| |
holes:Vector.<uint> (default = null) — An array of hole indices if any (e.g. [5, 8] for a 12-vertice input would mean one hole with vertices 5–7 and another with 8–11).
| |
dimensions:uint (default = 2) — The number of coordinates per vertice in the input array (2 by default).
|
Vector.<uint> — A flat array with each group of three numbers indexing a triangle in the `vertices` array.
|
| flatten | () | method |
public static function flatten(data:Vector.<Vector.<Vector.<Number>>>):ObjectTransforms multi-dimensional array (e.g. GeoJSON Polygon) into the format expected by earcut.
Parameters
data:Vector.<Vector.<Vector.<Number>>> — Arrays of rings, with the first being the outline and the rest holes. A ring is an array points, each point being an array of numbers.
|
Object |