https://github.com/juliageometry/earcut.jl
Wrapper for Mapbox's earcut.hpp for polygon triangulation
https://github.com/juliageometry/earcut.jl
Last synced: about 1 year ago
JSON representation
Wrapper for Mapbox's earcut.hpp for polygon triangulation
- Host: GitHub
- URL: https://github.com/juliageometry/earcut.jl
- Owner: JuliaGeometry
- License: other
- Created: 2016-12-22T15:03:09.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-17T05:52:41.000Z (over 3 years ago)
- Last Synced: 2025-03-29T06:48:17.877Z (about 1 year ago)
- Language: Julia
- Size: 754 KB
- Stars: 6
- Watchers: 9
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# EarCut
[](https://travis-ci.org/JuliaGeometry/EarCut.jl)
[](https://ci.appveyor.com/project/SimonDanisch/earcut-jl)
[](https://coveralls.io/github/JuliaGeometry/EarCut.jl?branch=master)
[](http://codecov.io/github/JuliaGeometry/EarCut.jl?branch=master)
Wrapper for [earcut.hpp](https://github.com/mapbox/earcut.hpp), a header only library for triangulating polygons.
License of wrapper: MIT
License of earcut.hpp: [ISC](https://github.com/JuliaGeometry/EarCut.jl.git/deps/earcut/LICENSE)
Install with:
```Julia
Pkg.add("EarCut")
Pkg.test("EarCut")
```
Usage:
```Julia
using EarCut, GeometryBasics
a = Circle(Point2f0(0), 0.5f0)
b = Circle(Point2f0(0), 1f0)
polygon = [decompose(Point2f0, b), decompose(Point2f0, a)] # some points defining a polygon. Must be a Vector{Vector{Point}}
triangle_faces = triangulate(polygon)
# then display with e.g. Makie like this:
using Makie, Colors
v = vcat(polygon...)
msh = GeometryBasics.Mesh(v, triangle_faces)
scene = Makie.mesh(v, triangle_faces; color = 1:length(v), shading = false, scale_plot = false, show_axis = false)
```
resulting in:
