JCash / voronoi

A C implementation for creating 2D voronoi diagrams
MIT License
622 stars 92 forks source link

Missing a way to get an indexed diagram #23

Closed trikko closed 5 years ago

trikko commented 5 years ago

Maybe I'm wrong, but I can't find a way to get an indexed diagram. I mean an array with the same size of bounding box where each element is the index of the cell.

Am I missing something?

JCash commented 5 years ago

You can get the generated sites as an array: // Returns an array of sites, where each index is the same as the original input point array. extern const jcv_site jcv_diagram_get_sites( const jcv_diagram diagram );

But since you mention the bounding box, I wonder if you want a voronoi diagram rendered to a texture? You can render it using your own "color", i.e. the index, see the example in main.c

This library is about generating the core data of a voronoi diagram, with edge and neighbor info. It's easier to go from this data to different renderings, than the other way around.