Skip to content

oberbichler/earcut.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Earcut.NET

Actions Status Codacy Badge

Earcut.NET is a port of earcut.js by Mapbox.

Usage

Call Earcut.Tessellate(vertices, holes) where vertices is a flat list of the vertex coordinates and holesis the list of hole indices.

var tessellation = Earcut.Tessellate(new double[] {
    0,   0,                 // Vertex 0 (outline)
  100,   0,                 // Vertex 1 (outline)
  100, 100,                 // Vertex 2 (outline)
    0, 100,                 // Vertex 3 (outline)
   20,  20,                 // Vertex 4 (hole)
   80,  20,                 // Vertex 5 (hole)
   80,  80,                 // Vertex 6 (hole)
   20,  80                  // Vertex 7 (hole)
}, new int[] {
   4                        // Index of the first Vertex of the hole
});

tessellation contains a flat list of vertex indices. Each group of three indices forms a triangle.

// Triangle 0:
var a_0 = tessellation[0];  // = 3
var b_0 = tessellation[1];  // = 0
var c_0 = tessellation[2];  // = 4

// Triangle 1:
var a_1 = tessellation[3];  // = 5
var b_1 = tessellation[4];  // = 4
var c_1 = tessellation[5];  // = 0

// Triangle 2:
var a_2 = tessellation[3];  // = 3
// ...

Please check out the earcut.js repository for more detailed information.

About

A small polygon triangulation library for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages