Generates images like these:
Essentially what the program does is manually color one (or more) pixel(s), then while there are blank pixels left, color a pixel next to a pixel that has already been colored.
The extreme variation comes from the many different ways to
- decide what pallette of colors to use.
- select which pixel to color next.
- select the color to use, based on the previous color.
If you want to try to understand the code, I tried to document it a bit. ImageGen.pde
is the entry point of the program, Colorizer.pde
has the code that starts the algoritm in another thread, ColorGenerators.pde
has the code that generates pallettes, DistCalculators.pde
contains the many methods to compare two colors, Blob.pde
has the class representing a growing blob of pixels, and Helpers.pde
contains various small classes to just better organize data.
-
Distance: Originally intended to be "a quantification of the visual difference between two colors," it devolved into "any way to compare two colors," and then "any way to generate an
int
based on two otherint
s." -
Pallette: A list of colors to be used up. Internally, it is an array of unique colors and an array of the number of each color, e.g.
{red, red, red, green, blue, blue}
is:colors = {red, green, blue} counts = { 3, 1, 2}
-
Nexel: One of the next pixels that could be colorized on the current tick.
-
Blob: A group of colorized pixels as well as all the nexels surrounding those pixels.
-
Here's what happens when we start the algorithm:
- Create an array "data" that holds the current color of each pixel.
- Instantiate one or more blobs.
- For each blob: select a pallette, select a distance calculator, and colorize one or more initial pixels.
- Create all the nexels for each of the inital pixels.
-
On each tick, for each blob:
- If the pallette is empty or there are no nexels left, destroy the blob, else:
- Pick a nexel using one of several methods (e.g. the oldest one, a random one, one of the 8 newest ones, etc.).
- Select a color from the specified pallette for that nexel, using the specified distance calculator to compare all colors from the pallette to the nexel's "parent's" color.
- Colorize the nexel and turn it into a "colorized pixel" by setting the color in the data array.
- Create new "children" nexels from the blanks in the data array around the current pixel.
- Tell the new nexels the color of their parent pixel.
While a thread runs the algoritm in realtime, the main loop of the program runs at a given framerate (usually 60fps). It reads the colors from the data array, and writes them to screen. Additionally, a .png
is saved whenever the [S] key is pressed.