New Pattern: Voronoi Mix 2D

I’ve just posted my latest experimental, “let’s see if we can get this to work” pattern to the library.

It’s… well… It draws an animated voronoi diagram with a variable number of moving points for starters.

It runs the voronoi distance algorithm, giving the user several different options for exactly how the distance is calculated and how the diagram is rendered. Lots of sliders. Something fun to play with while we’re all not out at parties tonight.

(This is another computationally heavy one, so start the number of points low, and if you’re using WS2812 LEDs, set your LED Type to “Buffered (2x Rate…” No video beause the number of different things it can do is quite large - easier to just give it a try.)


This is super coo! I love the mode sliders and combinations! Get’s decent frame rates on V3 with a 16x16 panel.

Two suggestions:

I think manhattan distance should be:

// manhattan distance -- distance with no diagonals
function manhattan(x,y) {
    return abs(x)+abs(y);

Otherwise a negative and a positive cancel out and it does only diagonal stripes. This gives more boxy 90 and 45 degree angles than Euclidean.

The other tweak I would do is avoid re-randomizing if the same control values are sent - currently only speed reinitializes them.

export function sliderSpeed(v) {
  var newSpeed = 0.15 * v;
  if (newSpeed != speed) {
    speed = newSpeed;

This lets you mess with the mode sliders and it keeps the patten stable, making it a lot easier to tell the difference between the various modes! Since all controls are sent every change (and another time when they persist), it calls the speed handler even if you change other settings.

This is definitely super cool pattern!

1 Like

You’re right! I’ll fix this tomorrow when sanity has returned. There are some slightly strange things in the comments too. I think, just maybe, it’s not a good idea to continue programming after the “celebrating” has started!


Ok… fixed manhattan distance, isolated all sliders, and added another distance method – a square wave filter over the manhattan distance, which makes nice “city block” patterns. It’s updated in my repository, and I’ll mail you the new epe version in a minute or two!

Here’s a short video segment (distance method 1, draw mode 4)


This is a neat pattern and is a great way to test your power supply. I have 768 LEDs in a matrix and this pulls over 4 amps at times! The regular 2.4A wall wart definitely does not suffice.