// CircleRandom // John Clavin, August 2008 Pencil adumbrate1; Pencil adumbrate2; Pencil adumbrate3; Pencil adumbrate4; Pencil adumbrate5; Pencil adumbrate6; int widthSeg; int heightSeg; int drawCount; void setup(){ size(664, 498); background(220); smooth(); strokeWeight(1); frameRate(18); widthSeg = width/4; heightSeg = height/3; adumbrate1 = new Pencil(widthSeg, heightSeg); adumbrate2 = new Pencil(widthSeg*2, heightSeg); adumbrate3 = new Pencil(widthSeg*3, heightSeg); adumbrate4 = new Pencil(widthSeg, heightSeg*2); adumbrate5 = new Pencil(widthSeg*2, heightSeg*2); adumbrate6 = new Pencil(widthSeg*3, heightSeg*2); } void draw() { adumbrate1.work(); adumbrate2.work(); adumbrate3.work(); adumbrate4.work(); adumbrate5.work(); adumbrate6.work(); drawCount++; if(drawCount > 200) { delay(6000); background(220); drawCount = 0; adumbrate1.reset(); adumbrate2.reset(); adumbrate3.reset(); adumbrate4.reset(); adumbrate5.reset(); adumbrate6.reset(); } } class Pencil { int centerX, centerY; int numPoints = 16; float radius, angle; float segment1, segment2; float x1, y1, x2, y2; int angleIndex = 0; color objColor; Pencil(int centerX, int centerY) { this.centerX = centerX; this.centerY = centerY; angle = TWO_PI/float(numPoints); objColor = color(random(210), random(210), random(210)); } void work() { stroke(objColor); radius = random(20, 100); segment1 = random(angle*angleIndex, angle*(angleIndex+1)); x1 = radius*cos(segment1)+centerX; y1 = radius*sin(segment1)+centerY; segment2 = random(angle*(angleIndex+8), angle*(angleIndex+9)); x2 = radius*cos(segment2)+centerX; y2 = radius*sin(segment2)+centerY; line(x1, y1, x2, y2); angleIndex++; } void reset() { angleIndex = 0; objColor = color(random(210), random(210), random(210)); } }