Voronoi Node
A Voronoi Diagram partitions a plane with points into polygons such that each polygon contains exactly one generating point and every point in a given polygon is closer to its generating point than to any other. The patterns produced are beautiful, often found in nature, and are useful both for generative art and data visualization. More about Voronoi patterns here:
https://fbellelli.com/posts/2021-07-08-the-fascinating-world-of-vor...
Our new Nodebox Voronoi node is my third collaboration with Floris de Jonge, who developed the prototype using Claude AI. More about that here:
http://support.nodebox.net/discussions/general-discussion/15341-ai-...
For this official version, I further modified the v4 prototype to allow an optional point list. I then wrapped it in a subnetwork so that I could gain more control over the boundary shape used to form the final regions. The node now works with curved shapes even if they have contours, so is great for pulverizing text paths. Voronoi requires version 5 of the python module, now called Voronoi.py.
Voronoi takes five parameters:
- Boundary. The shape to be partitioned.
- Optional Point List. A list of points used to define the polygonal cells. If no list is provided, random points will be generated.
- Cell Count. The number of random cells desired. Minimum is 2. Ignored if a point list is supplied.
- Seed. A seed controlling the randomly generated cell points. Ignored if a point list is supplied.
- Cell Margin. Additional space added between the cells.
In general, the node will return one cell for each point requested, but under some circumstances one or two points may not generate a cell. The algorithm initially produces polygonal cells based on a polygonal version of the boundary shape. I then intersect the cells with the original shape to produce curved outer edges (if present) and remove hole contours in shapes like letters.
The algorithm insists on a minimum point separation. This normally is not a concern, but can cause missing cells in small boundary shapes. If this happens, increase the size of your boundary shape and then, once you are happy with the results, scale the cells back down to whatever size you need. If pulverizing text, set the font size big (100 or more), then scale down afterwards if needed. In rare cases certain artifacts may arise; if you don't like the way your cells look, just adjust the point list or change the seed.
Unlike some Voronoi generators, this node often produces variable gaps between cells even when cell margin is 0. I prefer to consider this a feature, not a bug.
The attached demo shows four examples, colored using my Werner_color node:
- Upper Left. A Reuleaux Triangle partitioned into 81 cells using points created by a scatter node.
- Upper Right. A rectangle partitioned into 10 cells using a scaled scatter node to avoid points near the edges. (There is no problem with points near the edges, but I wanted them tucked in for aesthetic reasons.). For this example I also show the points as red dots. The points within the area of each cell are closer to its seed dot than to any other dot.
- Lower Left. A text path (percentage sign) using randomly generated points (no point list supplied). The percentage sign is challenging because it contains FIVE contours, three separate shapes (a slash and two loops) with a hole in each loop.
- Lower Right. A circle partitioned using a slightly wiggled grid and extra cell margin. This demonstrates one of countless ways to gain more control over the final pattern by controlling the point list.
Feel free to adjust the settings on any of these examples, try different shapes or characters, etc. As always, if you find any problems - or just wish to share an interesting result, please let me know.
-
voronoi_screenshot.png
808 KB
- voronoi_demo.zip 94.3 KB
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac