![getting the voronoi texture to be the same colorblender getting the voronoi texture to be the same colorblender](https://docs.blender.org/manual/en/latest/_images/editors_texture-node_types_textures_voronoi_node.png)
First, the outer cells which have dangling edges need to be closed. The last step is to create the actual polygons (see voronoi_polygons method). That is, for each edge find the two nearest input points (=cells) and create a mapping from that. For that I use the proposed solution of Alink from a related question. Then, in the voronoi_cell_lines method I determine which edges belong to which cells. The code is at and extends on the solution of tauran.įirst, I changed the code to give me vertices and (pairs of) indices (=edges) separately, as many calculations can be simplified when working on indices instead of point coordinates.
#GETTING THE VORONOI TEXTURE TO BE THE SAME COLORBLENDER HOW TO#
Lines = LineCollection(lines, edgecolor='k')Īs I spent a considerable amount of time on this, I'd like to share my solution on how to get the Voronoi polygons instead of just the edges. Vc = np.nan # edges at infinity, plotting those would need more work.įrom llections import LineCollection # The following is just a direct transcription of the formula thereĬc = cross2(sq2(a) * b - sq2(b) * a, a, b) / (2*ncross2(a, b)) + C
![getting the voronoi texture to be the same colorblender getting the voronoi texture to be the same colorblender](https://i.stack.imgur.com/hZmxY.jpg)
It's still probably possible, but needs some more thinking.
![getting the voronoi texture to be the same colorblender getting the voronoi texture to be the same colorblender](https://docs.blender.org/manual/en/dev/_images/render_shader-nodes_textures_voronoi_example-hammered-metal.jpg)
Unfortunately, the code does not expose the circumcenters to the user at the moment, so you'll have to recompute those yourself.Īlso, the Voronoi edges that extend to infinity are not directly obtained in this way. The adjacency information can be found in the neighbors attribute of the Delaunay object.