# Coloring a Voronoi Graph

Intro:

I want to convert a Voronoi Graph made with this awesome library by jceipek on GitHub into something I can work on.

So far so good, this user provides with a demo to start with and shows how to generate the VG.

Question:

How do I convert the VG (made by edges and that dot in the middle) into something that I can work with?

Such as, after you generate some noise and apply to it (height), you colour the polygons based on it.

Thoughts:

Something comes to my mind about instantiating meshes and tiles based on the edges and the position of the dot as a start, but it won't work if I can't "detect" the polygon.

Expected result:

What I have:

It is drawn with Gizmos (for visual debugging in Unity)

I want to know how to color my polygons as in the expected image above. So I thought about doing a mesh or individual tile (and color it based on height afterwards but that is sauce for another question if needed)

Edit of my progress:

To further explain this question I provide the next image.

The image shows that I could use that position data somehow and turn that random polygon shape into a "tile" that will have a colour (mesh?) and possible data in it (script).

I hope this helps otherwise let me know in the comments.

• To be clear, you're asking about "rendering" a Voronoi graph, correct? Not about graph colouring (the algorithmic problem of choosing "colour" labels so that no two adjacent nodes use the same label)? If so, I recommend editing your title to avoid confusion, and including an example image or mock-up of what your input and desired output look like. Aug 20 '18 at 10:31
• Edit done with my expected results about it. Aug 20 '18 at 10:58
• Can you be more clear about "into something i can work on" - what do you exactly need and expect? A model, a bitmap, a vector image, a something else? Aug 20 '18 at 10:59
• Hm... it's not clear to me how this image relates to "after you generate some noise and apply to it (height) you colour the polygon based on it." Can you explain step-by-step? And define what "it" is in each case (the graph? The noise value? The resulting height?) Aug 20 '18 at 11:00
• Might the last comment in this thread (by Yandalf) be what you are looking for? forum.unity.com/threads/… Aug 20 '18 at 11:17

If you check Voronoi.cs there is a method called Regions () which returns a List<List<Vector2>>. Each sub list is list of points for a given region. From there you can turn the points into a mesh.
• In addition to where it is suggested to use Regions(), OP will also want to construct a sub-mesh for each tile, set its vertex colours according to the colour you want, and then use a vertex colouring shader / material on it. Alternatively pick a material on which the colour can be set as a whole. Nov 23 '18 at 5:39