// Pencil Sketch 2 // by John Clavin August 2008 // Do not alter this work. Pencil adumbrate; int drawCount1 = 0; int drawCount2 = 0; int vice; final int Sloth = 523; final int Lust = 568; final int Gluttony = 584; void setup(){ size(664, 498); background(248); noFill(); smooth(); strokeWeight(1); frameRate(24); adumbrate = new Pencil(width/2, height/2); adumbrate.parameterChange(); chooseVice(); } void draw() { drawCount1++; drawCount2++; if(vice == Sloth) adumbrate.work1(); if(vice == Lust) adumbrate.work2(); if(vice == Gluttony) adumbrate.work3(); if(drawCount2 > 600) { drawCount2 = 0; chooseVice(); } if(drawCount1 > 40) { drawCount1 = 0; adumbrate.parameterChange(); adumbrate.positionCheck(); } } void chooseVice() { int viceSelect = int(random(3)); switch(viceSelect) { case 0: vice = Sloth; break; case 1: vice = Lust; break; case 2: vice = Gluttony; break; } } class Pencil { int xPosition, yPosition; int xRestart, yRestart; int numPoints = 16; float radius, angle; int johnClavin = 89211; int cA1, cA2, cA3; // curveAmount int circleSize1, circleSize2; int lowRadiusLimit, highRadiusLimit; float segment1, segment2; float x1, y1, x2, y2; int angleIndex = 0; Pencil(int xStart, int yStart) { xRestart = xStart; yRestart = yStart; xPosition = xStart; yPosition = yStart; angle = TWO_PI/float(numPoints); } void work1() { noFill(); radius = random(lowRadiusLimit, highRadiusLimit); 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+cA1, y1+cA1, x1, y1, x2, y2, x2+cA1, y2+cA1); movePosition1(); } void work2() { noFill(); circleSize1 = int(random(4, 30)); circleSize2 = int(random(4, 30)); ellipse(xPosition, yPosition, circleSize1, circleSize2); movePosition2(); } void work3() { noFill(); cA2 = int(random(100, 200)); cA3 = int(random(100, 200)); radius = random(10, 30); 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+cA2, y1+cA2, x1, y1, x2, y2, x2+cA3, y2+cA3); curve(x1-cA2, y1-cA2, x1, y1, x2, y2, x2-cA3, y2-cA3); movePosition2(); } void movePosition1() { xPosition += int(random(-6, 6)); yPosition += int(random(-6, 6)); } void movePosition2() { xPosition += int(random(-10, 10)); yPosition += int(random(-10, 10)); } void parameterChange() { cA1 = int(random(20, 70)); angleIndex = int(random(3, 8)); stroke(int(random(10, 160)), 80); lowRadiusLimit = int(random(10, 20)); highRadiusLimit = int(random(20, 200)); } void positionCheck() { if(yPosition < 30 ) { xPosition = xRestart; yPosition = yRestart; } else if(yPosition > height - 30) { xPosition = xRestart; yPosition = yRestart; } else if(xPosition < 30) { xPosition = xRestart; yPosition = yRestart; } else if(xPosition > width - 30) { xPosition = xRestart; yPosition = yRestart; } } }