EarCut
Wrapper for earcut.hpp, a header only library for triangulating polygons.
License of wrapper: MIT
License of earcut.hpp: ISC
Install with:
Pkg.add("EarCut")
Pkg.test("EarCut")
Usage:
using EarCut
using GeometryTypes
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. GLVisualize like this:
using GLVisualize, Colors; w = glscreen(); @async renderloop(w)
v = map(x-> Point3f0(x[1], x[2], 0), vcat(polygon...))
mesh = GLNormalMesh(vertices=v, faces=triangle_faces)
_view(visualize(mesh), camera = :orthographic_pixel)
GLAbstraction.center!(w, :orthographic_pixel)
resulting in: