Fill a mesh Delaunay object

Hi @BrokenCode,

I’m not really familiar with Lee Byron’s “mesh” library but here is my two cents:

  • getRegions() only work with Voronoi objects
  • the “Triangulate” library seems more appropriate in your case

You just need to:

  • download it here

  • import it in your sketch

    In setup()

  • put all the points (PVector) you want to triangulate in an array list (let’s call it plist)

  • call the triangulate method on that list: -> triangles = Triangulate.triangulate(plist)

  • display the triangles with the beginShape(TRIANGLES) function and fill them as you like:

beginShape(TRIANGLES)
for t in triangles:
    fill(random(255), random(255), random(255))
    vertex(t.p1.x, t.p1.y)
    vertex(t.p2.x, t.p2.y)
    vertex(t.p3.x, t.p3.y)
endShape()

4 Likes