// Color Theme and Variation 4 // by John Clavin, June 2008 // Do not alter this work. color[] colorArray = new color[21]; color[][] colorVarArray = new color[13][21]; int[][] varOffsetArray = new int[13][3]; float plusAdj; float minusAdj; float verticalSeg; float horizontalSeg; int drawCount = 0; void setup() { size(780, 482); background(255); noStroke(); smooth(); frameRate(.5); plusAdj = 28; minusAdj = plusAdj/2*-1; verticalSeg = (height + plusAdj)/14; horizontalSeg = (width + plusAdj)/22; colorSetup(); createColorVar(); colorVarSetup(); } void draw() { background(255); drawCount++; for( int a = 1; a < 14; a++) { for( int b = 1; b < 22; b++) { fill(colorVarArray[a-1][b-1]); ellipse(int(horizontalSeg*b+minusAdj), int(verticalSeg*a+minusAdj), 36, 36); } } if(drawCount > 6) { colorSetup(); drawCount = 0; } createColorVar(); colorVarSetup(); } void colorSetup() { int variationSelect = int(random(2)); switch(variationSelect) { case 0: for(int i = 0; i < 21; i++) { colorArray[i] = createColor1(); } break; case 1: for(int i = 0; i < 21; i++) { colorArray[i] = createColor2(); } break; } } void colorVarSetup() { for(int i = 0; i < 13; i++) { for(int j = 0; j < 21; j++) { int R = colorArray[j] >> 16 & 0xFF; int G = colorArray[j] >> 8 & 0xFF; int B = colorArray[j] & 0xFF; R += varOffsetArray[i][0]; G += varOffsetArray[i][1]; B += varOffsetArray[i][2]; colorVarArray[i][j] = color(R, G, B); } } } color createColor1() { int colorSelect = int(random(6)); int R = 0; int G = 0; int B = 0; switch(colorSelect) { case 0: R = int(random(100, 240)); G = int(random(20, 100)); B = int(random(20, 100)); break; case 1: R = int(random(20, 100)); G = int(random(100, 180)); B = int(random(20, 100)); break; case 2: R = int(random(20, 100)); G = int(random(20, 100)); B = int(random(100, 230)); break; case 3: R = int(random(100, 200)); G = int(random(100, 180)); B = int(random(20, 100)); break; case 4: R = int(random(20, 100)); G = int(random(100, 180)); B = int(random(100, 200)); break; case 5: R = int(random(100, 200)); G = int(random(20, 100)); B = int(random(100, 200)); break; } return color(R, G, B); } color createColor2() { int R = int(random(100, 160)); int G = int(random(100, 160)); int B = int(random(100, 160)); return color(R, G, B); } void createColorVar() { int johnClavin = 89239; for(int i = 0; i < 13; i++) { for(int j = 0; j < 3; j++) varOffsetArray[i][j] = int(random(-50, 50)); } }