Earcut Module
Functions and values
| Function or value |
Description
|
Full Usage:
arrayZeroCreateFloat len
Parameters:
int
Returns: float[]
Modifiers: inline |
Creates a float array of the given length, initialized to zero. (a Float64Array when compiled with Fable)
|
Full Usage:
arrayZeroCreateInt len
Parameters:
int
Returns: int[]
Modifiers: inline |
Creates an int array of the given length, initialized to zero. (an Int32Array when compiled with Fable)
|
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:
earcutTriangles holes boundary
Parameters:
IList<ResizeArray<float>>
-
An IList of holes, where each hole is an ResizeArray of x and y . Use `null` or empty array if there are no holes.
boundary : ResizeArray<float>
-
An ResizeArray of x and y coordinates 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.
|
Triangulates a polygon with holes, given as ResizeArray flat X and Y coordinates. Any object with x and y properties will work as a point object. (via F# statically resolved type parameters)
|
Full Usage:
earcutTrianglesFromMembersXY 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:
earcutTrianglesFromMembersxy 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).
|
Full Usage:
refine (triangles, coords, dim)
Parameters:
ResizeArray<int>
-
Triangle indices, as returned by the earcut function; mutated in place.
coords : float array
-
The flat vertex coordinates passed to the earcut function.
dim : int
-
The number of coordinates per vertex in coords: 2 if it is made of x and y coordinates only.
|
Refines a triangulation toward the constrained Delaunay triangulation by legalizing every interior edge in place with Lawson flips - maximizing the minimum angle and removing most slivers. An optional post-pass for the output of the earcut function, or any manifold triangle-index list indexing into coords. Adapted from delaunator's edge legalization. Uses non-robust predicates: float input is fine, and the worst case is a not-quite-Delaunay edge, never an invalid mesh.
|
Full Usage:
validate (vertices, holeIndices, dimensions)
Parameters:
float array
holeIndices : int array
dimensions : int
|
Validates the input data for the earcut function. Raises a descriptive System.ArgumentException if the input is invalid. Checks include: - dimensions is at least 2 - vertices array is not null or empty - vertices array length is a multiple of dimensions - no NaN or Infinity values in the vertices array - the outer loop has at least 3 points - each hole has at least 3 points (or 1 point for Steiner points) - hole indices are within bounds and in ascending order - the total area of all holes is smaller than the area of the outer loop
|
Earcut