Earcut Module
Functions and values
| Function or value |
Description
|
Full Usage:
deviation (vertices, holeIndices, dim, triangles)
Parameters:
float array
holeIndices : int array
dim : int
triangles : ResizeArray<int>
Returns: float
|
Utility function to verify correctness of the triangulation. Returns a percentage difference between the polygon area and its triangulation area. used to detect any significant errors in the triangulation process.
|
Full Usage:
earcut (vertices, holeIndices, dimensions)
Parameters:
float array
-
A array of vertex coordinates like [x0, y0, x1, y1, x2, y2, ...].
holeIndices : int array
-
An array of hole starting indices in the vertices array.
This index refers to the actual point array. Not the flattened vertices array.
If you have the index in the flattened vertices array, you need to divide it by the dimensions parameter to get the correct index parameter.
Use `null` if there are no holes.
dimensions : int
-
The number of coordinates per vertex in the vertices array:
2 if the vertices array is made of x and y coordinates only.
3 if it is made of x, y and z coordinates.
Returns: ResizeArray<int>
A list of integers.
They are indices into the points array.
so if you use the flattened vertices array, you need to multiply the index by the dimensions parameter to get the correct index in the vertices array.
e.g.:
(if dimensions = 2)
|
Triangulates a polygon with holes, given as flat array of numbers.
|
Full Usage:
earcut_XY holes pts
Parameters:
IList<ResizeArray<^T>>
-
An IList of holes, where each hole is an ResizeArray of points. Use `null` or empty array if there are no holes.
pts : ResizeArray<^T>
-
An ResizeArray of points representing the outer polygon.
Returns: float[]
A flat array of vertex coordinates like [x0, y0, x1, y1, x2, y2, ...] representing the triangulation of the polygon.
Every six consecutive values represent a triangle in 2D space.
Modifiers: inline Type parameters: ^T |
Triangulates a polygon with holes, given as arrays of objects with X and Y properties (Uppercase). Any object with X and Y properties will work as a point object. (via F# statically resolved type parameters)
|
Full Usage:
earcut_xy holes pts
Parameters:
IList<ResizeArray<^T>>
-
An IList of holes, where each hole is an ResizeArray of points. Use `null` or empty array if there are no holes.
pts : ResizeArray<^T>
-
An ResizeArray of points representing the outer polygon.
Returns: float[]
A flat array of vertex coordinates like [x0, y0, x1, y1, x2, y2, ...] representing the triangulation of the polygon.
Every six consecutive values represent a triangle in 2D space.
Modifiers: inline Type parameters: ^T |
Triangulates a polygon with holes, given as arrays of objects wit x and y properties (lowercase). Any object with x and y properties will work as a point object. (via F# statically resolved type parameters)
|
Full Usage:
flatten data
Parameters:
float[][][]
Returns: (type)
|
Utility function to turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts Returns an object with the following properties: - vertices: a flat array of vertex coordinates like [x0, y0, x1, y1, x2, y2, ...]. - holes: an array of hole starting indices in the vertices array. Use `null` if there are no holes. - dimensions: the number of coordinates per vertex in the vertices array. derived from the first vertex in the data array (e.g. 2 if the vertices array is made of x and y coordinates only, 3 if it is made of x, y and z coordinates).
|
Earcut