// Pencil Sketch 5 (Viral Expansion with Mutation) // by John Clavin, September 2008 // Do not alter this work. Pencil drawingObject; int drawCount = 0; int yCenter; int hI = 0; // horizontal increment void setup(){ size(780, 482); background(248); noFill(); smooth(); strokeWeight(1); frameRate(10); yCenter = height/2; drawingObject = new Pencil(); } void draw() { drawCount++; drawingObject.work(hI = hI + 8, yCenter, 5); if(drawCount > 120) { drawCount = 0; delay(10000); background(248); drawingObject.resetMutation(); hI = 0; } } class Pencil { int xPosition, yPosition; int numPoints = 16; int angleIndex; int johnClavin = 89214; int cA1, cA2; // curveAmount int strokeAmount; int m = 0; int mutation = 0; float segment1, segment2; float x1, y1, x2, y2; float radius, angle; Pencil() { angle = TWO_PI/float(numPoints); } void work(int x, int y, int level) { xPosition = x; yPosition = y; mutation = m++/8; cA1 = int(random(20, 180)); cA2 = int(random(20, 180)); strokeAmount = int(random(10, 140)); stroke(strokeAmount, 180); angleIndex = int(random(0, 8)); for(int i = 0; i < 12; i++){ radius = random(20, 50); segment1 = random(angle*angleIndex, angle*(angleIndex+1)); x1 = radius*cos(segment1)+xPosition; y1 = radius*sin(segment1)+yPosition; segment2 = random(angle*(angleIndex+8), angle*(angleIndex+9)); x2 = radius*cos(segment2)+xPosition; y2 = radius*sin(segment2)+yPosition; curve(x1+mutation, y1+cA1, x1, y1, x2, y2, x2-mutation, y2+cA2); } if(level > 1) { level--; work(int(x1), int(y1), level); work(int(x2), int(y2), level); } } void resetMutation() { m = 0; mutation = 0; } }