earcut
A library for efficiently transforming polygons into triangles in go.
About
This is a direct port of Mapbox's JavaScript earcut library.
Usage
// flat array of all vertices in polygon, including holes
verts := []float64{
0.0, 0.0,
1.0, 0.0,
1.0, 1.0,
0.0, 1.0,
0.0, 0.0,
0.25, 0.25,
0.75, 0.25,
0.75, 0.75,
0.25, 0.75,
0.25, 0.25,
}
holes := []int{5} // *vertex* index of beginning of each hole
dims := 2 // number of values per vertex
indices, err := earcut.Earcut(verts, holes, dims)
// indices is an array of integers (3 per triangle) referencing
// the polygon vertexes that make up each triangle
Documentation
See Mapbox and GoDoc.org for complete documentation.
Author
Original implementation by Mapbox. Go port by Ryan Clancey
License
earcut is licensed under the ISC license, described in the LICENSE
file.