I wrote a simple program to generate random Voronoi Diagrams in C, and I’m satisfied with how it works.

Why does this matter? Well, for one you can make some pretty cool images for backgrounds.

Right now, a slow, naive algorithm is used to find what color is pixel is. I plan on changing this in the future.

Beneath each image is the command I used to generate the image. If you want to make your own images, download the git repo, and be sure to convert the created .ppm file into a sane format, like .png which takes up far less space.

Example Images

Voronoi Diagram 1

./voronoi -p 10

Voronoi Diagram 2

./voronoi -p 1000 -c rainbow

Voronoi Diagram 3

./voronoi -p 1000 -c blues

And finally, my favorite: Voronoi Diagram 3

./voronoi -w 4096 -t 2304 -p 9001 -c toxic

Creating Your Own Themes

There’s a small set of themes included, which can get boring after a while, so let’s make some themes.

The syntax for creating your own theme is pretty simple. It’s similar to an INI file’s syntax, with the theme name being in a format such as [themename], and the following values being hexadecimal color values. Blank lines are ignored, here’s an example theme:

[patriot]
FFFFFF
FF0000
0000FF

This will create a theme called patriot which has the colors red, white, and blue.

You can get the code here.