//a self-replicating drawing class //inspired by the work of Jared Tarbell //2008 robert carlsen // robertcarlsen.net int initialCount = 5; int count = initialCount; LiveLine lines[]; boolean recording = false; boolean doRecord = false; void setup(){ //faster with opengl, doesn't seem to work in a browser size(500,500); initLines(count); } void draw(){ smooth(); //loop through multiple times to speed up the drawing rate...to a point for(int j=0; j= count) { //println("All dead!"); //restart initLines(initialCount+=2); } } } void initLines(int num) { lines = new LiveLine[num]; count = num; for (int i=0; i.5){ if((count+=2)>=lines.length){ //dynamically expand the lines array as necessary lines = (LiveLine[]) expand(lines); } float newx = cos(a)*segment; float newy = sin(a)*segment; float newa = random(PI); float newspeed = speed*.90; lines[count-2] = new LiveLine(x+newx,y+newy,a+newa,weight*.5, newspeed); newa = random(PI); lines[count-1] = new LiveLine(x-newx,y-newy,a+newa,weight*.5,newspeed); //println("lines array length: " + lines.length); //println("current count: " + count); } //kill the current line, so i won't spawn any further dead = true; } popMatrix(); } }