Dozed12 / p5.voronoi

A Voronoi library for p5.js
MIT License
128 stars 18 forks source link

Is there a way to create an irregularly-shaped diagram instead of a rect? #5

Closed arwalton closed 3 years ago

arwalton commented 3 years ago

I'm doing a project where I overlay a diagram on a map to show the location of the nearest hospital in an area. Unfortunately, the mapped area is not very rectangular, so the diagram has very large cells around the edges that go into surrounding areas. Is there an elegant way to create a border on the voronoi diagram that more nearly matches the borders of the mapped area?

Dozed12 commented 3 years ago

Unfortunately there is no elegant way around it, Fortune's algorithm used by this library requires the space to be a rectangular shape. You will have to manually remove the external areas to fit your map, possibly by drawing the diagram separately and then applying a mask to it.

arwalton commented 3 years ago

No worries. Thanks for letting me know. I'll rig up a solution then.