// Color Theme and Variation 1 // by John Clavin, May 2008 // Do not alter this work. color jColor1; color jColor1Var; color jColor2; color jColor2Var; color jColor3; color jColor3Var; int[] varArray = new int[3]; int drawLoopCount = 0; void setup() { size(780, 482); background(248); strokeWeight(1); smooth(); frameRate(13); colorSetup(); } void draw() { drawLoopCount++; stroke(jColor1); sketch(width*21/100, height*28/100); stroke(jColor2); sketch(width/2, height*28/100); stroke(jColor3); sketch(width*79/100, height*28/100); stroke(jColor1Var); sketch(width*21/100, height*72/100); stroke(jColor2Var); sketch(width/2, height*72/100); stroke(jColor3Var); sketch(width*79/100, height*72/100); if(drawLoopCount > 120) { delay(8000); background(248); colorSetup(); drawLoopCount = 0; } } void sketch(int x, int y) { int leftDim; int rightDim; int upDim; int downDim; int dim; dim = int(random(80, 160)); leftDim = dim; rightDim = dim; upDim = dim; downDim = dim; line(x - leftDim, random(y - upDim, y + downDim), x + rightDim, random(y - upDim, y + downDim)); dim = int(random(80, 130)); leftDim = dim; rightDim = dim; upDim = dim; downDim = dim; line(random(x - leftDim, x + rightDim), y - upDim, random(x - leftDim, x + rightDim), y + downDim); } void colorSetup() { createColorVar(); jColor1 = createColor(); jColor1Var = applyColorVar(jColor1); jColor2 = createColor(); jColor2Var = applyColorVar(jColor2); jColor3 = createColor(); jColor3Var = applyColorVar(jColor3); } color createColor() { int colorSelect = int(random(6)); int R = 0; int G = 0; int B = 0; switch (colorSelect) { case 0: R = int(random(200, 255)); G = int(random(200)); B = int(random(200)); break; case 1: R = int(random(200)); G = int(random(200, 255)); B = int(random(200)); break; case 2: R = int(random(200)); G = int(random(200)); B = int(random(200, 255)); break; case 3: R = int(random(140, 255)); G = int(random(140)); B = int(random(140)); break; case 4: R = int(random(140)); G = int(random(140, 255)); B = int(random(140)); break; case 5: R = int(random(140)); G = int(random(140)); B = int(random(140, 255)); break; } return color(R, G, B); } void createColorVar() { varArray[0] = int(random(-75, 75)); varArray[1] = int(random(-75, 75)); varArray[2] = int(random(-75, 75)); } color applyColorVar(color c) { int R = c >> 16 & 0xFF; int G = c >> 8 & 0xFF; int B = c & 0xFF; R += varArray[0]; G += varArray[1]; B += varArray[2]; return color(R, G, B); }