A small c++ program to create images like the one below. The core algorithm was written in about 2 hours.
The source code is on Github: https://github.com/shamanDevel/PixelRain
(Actually, this is a collage of four output images, representing the four elements fire, water, air, earth)
This is how the algorithm works:
- Define a random distribution that generates colors. Different distributions produced the different results above.
- Define a similarity function that computes how similar two colors are. Here it is important which color space is used. I usually use the HCL color space because it results in color gradients that look more natural to a human than a simple RGB-distance.
- Pick a seed pixel and fill it with a random color according to the distribution.
- Until all pixels are filled:
- Sample a new color from the distribution
- From all already filled pixels that have neighbors without a color assigned, search the one with the lowest distance according to the similarity function
- Place the new pixel at one of the neighbors of the pixel found in step 4.2.