PImage MyImage; //define an image int [][] memory; //use it as a copy of the image’s data void setup(){ size(400,400); MyImage = createImage(width, height, RGB); for(int x=0; x0.5) //create a random bitmap set(x,y,color(0,0,0)); else set(x,y,color(255,255,255)); } memory = new int[width][height]; } void draw(){ image(MyImage,0,0); //just draw the image in its new state } int gen = 0; //marks the number of generations void keyPressed(){ for(int x=5; x=5) //if all black neighbors are greater or equal to memory[x][y]=255; //become white } for(int x=0; x