#ksawerykomputery #creativecoding #pixels #displays #generative #newmediaart #mixedmedia #processing #arduino #musicvideo #vj #diy #ksawerykomputery #creativecoding #pixels #displays #generative #newmediaart #mixedmedia #processing #arduino #musicvideo #vj #diy

Cellular Automata Generator

a Processing tool for generating images and videos based on Cellular Automata concept. change rules and colour palettes on the go, add your images, use brushes and share the results with other sketches or applications via Syphon. sync to music for live performances!

download app (MacOSX, Windows)

download source (pde)

how does it work?


my interest in CA (Cellular Automata) began the day I accidentaly hit the CelLab website. until then the only CA i knew was Conway’s Game of Life. CelLab project amazed me with its features – a list of different rules and colour palettes. i desperately wanted to work with it on my own terms and build a tool.

my basic goals were:

  • to keep the idea of a list of rules and colour palettes
  • to change settings (rules/colour palettes) as easily as possible (with one mouse click or a keyboard shortcut) and without a need to restart the program
  • to add images during calculations (not only as a basic state)
  • to draw your own pictures (simple mouse painter)
  • to capture the results as a video or a screenshot
  • to easily share the results live with other programs or sketches (Syphon)
  • make it useful in VJ-ing (make automatic changes synced to specific tempo or midi clock)

it took me months to finally get to the point i feel i can share the result.

about CA

in brief: the idea of CA is to generate an array of states (pixels of an image) from another array of states using a specific function (a rule). the new array is called a next generation and is simply a next video frame. if you generate the frames constantly you will get an animation.

Conway’s Game of Life

Conway’s Game of Life

a rule applies to every pixel of an image and usually depends on other pixels from a previous frame. the most popular CA rule is called Game of Life, a 2D binary array in which every pixels depends on its closest neighbours. in every frame and for every pixel you read its current state (0/1 or dead/alive), then count its alive neighbours (0-8) and due to the rule below you get a new state:

Conway’s Game of Life Rules

newState = currentState; if (currentState == 1) { if (neighbours < 2 || neighbours > 3) { newState = 0; } } else { if (neighbours == 3) { newState = 1; } }

Game of Life is just one of CA rules. CA can work with other range of states (ie. 256 values of gray) and in 1D arrays, 2D or 3D, or whatever you want. you can find some cool 3D examples in the web. it also doesn’t necessarily have to be squares. anyway, i decided to work with 2D 256-states array, which fits a grayscale animation.

run the project

if you downloaded the sketch, to run a project you also need to have Syphon and oscP5 libraries installed. they are easy to find in Processing menu. if you do, the sketch should run right away without any issues.

this is what the interface should look like:

CA Interface

the left square contains a preview of a current frame. if you turn on Syphon in the main Tab, this is what is sent to other programs or sketches.

next, you find lists for Rules, Palettes, Images, Brushes, Generate functions and Settings. all of these are available under keyboard shortcuts. you move between parts by pressing 1-5 nums. each option has a shortcut printed close to its name.


the rules i developed in my project are quite simple and i only take them as examples. i encourage you to make up and write your own conditions.

the most common function i use to generate next frame is checkState(int x, int y, int xTranspose, int yTranspose). with it i always deliver values of 8 closest neighbours: nn, ne, ee, se, ss, sw, ww, nw. the rule always result with newState value.

let’s take Plasma Rule as another example. here, for every pixel i copy the value of one of the pixels around [nn, ne, ee, se, ss, sw, ww, nw] depending on noise(x,y) function:

CA Plasma

CA Plasma Rule

in Expand Rule i set every black pixel to the brightness value of a random neighbour and decrease this value by 5:

CA Expand

CA Expand Rule

some of the rules are dedicated especially for drawing, like the White Shadow rule.

CA White Shadow

CA White Shadow

sometimes you don’t even need to think of the neighbours. simply increase the newState value every frame to get a Blink effect:

CA Blink

CA Blink Rule


every rule in this project operates on 256 states (256 shades of gray), which means that Grayscale is a basic colour scheme. i wanted to make the visual result look fancier and more diverse, so i added colour mapping (often called Gradient Map). the idea behind it is to change every of 0-255 grays due to a specific colour preset (Palette).

CA Palettes examples

CA Palettes examples

creating new palette is simple and you can find different approaches to do this in the code. you have to fill an array named colour paletteStopsList[256] with as many colour stops as you like. basically it automatically fills the gaps with gradients. you can use noGradients() at the beginning to prevent it. also, you can make a palette build randomly, like i did to few of my palettes.


you can insert an image from the sketch library in any moment you want. if you’d like to use your own images, simply copy your files to /data/images/ directory and add them in OP_IMAGES tab. the project will apply a greyscale filter and convert pure black to transparent by default.

CA Images

CA Images


drawing is another way to interact live with the screen. you can find 4 brushes at your disposal: rectangle, line, smooth or spray.

CA Rectangle Brush

CA Rectangle Brush


i also added few "generative" effects possible to apply:

  • Contra – inverts a random part of the frame
  • Noise – changes every pixel to a random value
  • Snow – adds few white pixels in random places
  • Glitch – copies a random part of the frame and pastes in a random place
  • Flatten – changes a random part of gradient colours to a solid colour
CA Glitch

CA Glitch


the last part of the interface includes settings. here, you can:

  • pick a display size in a range from 8x8 to 512x512
  • start/pause the rule
  • clear screen
  • turn on the Automator (described below)
  • turn on recording – frames are saved to /movies/ directory
  • save screen as .tif file /screenshots/ directory
  • copy/paste the current frame to clipboard
  • pick a new array of Perlin noise (used in Perlin rule)

sync to music (Automator)

if you’d like to use all these features for a visual performance synced to music, then i recommend downloading Automator extension. this is a small Processing sketch i wrote, which captures your mouse clicks and keyboard presses, put them on a timeline and repeatedly send back. it works like a looper for your actions – it changes rules, palettes, add images, etc. in the rhythm you program it to. sketch requires OscP5 communication (one of basic libraries). all you have to do is run both Automator and CA sketches, then turn the Automation on in CA.



what next?

if you have any idea how to improve this tool or simply would like to help developing it, then i’m more than happy to cooperate. if you got any problems using it or find a bug, also please let me know. enjoy!

Show comments 💬