Rothera_alex-13-9-65
///Alex Rothera 1/23/12 //Interactive Art and Computational Design PVector v1, v2, v3, v4, v5, v6, v7; void setup() { size(800, 800); smooth(); background(255); frameRate(.2); stroke(0); strokeWeight(1.5); } void draw() { fill(255); rect(0, 0, width, height); noFill(); rect(1, 1, width-3, height-3); int overallHorz = floor(random(5, 10)); // # overall divisions float horizSpacing = height/overallHorz; //horizontal spacing distance int horizDivisions = 8; PVector [] [] gridXY = new PVector[horizDivisions] [overallHorz]; //2D array to hold ref. points ///GRID CREATION ///establish/store x and y for (int i=0; i<overallHorz; i++) { for (int j=0; j<horizDivisions; j++) { float tempY = (horizSpacing*i) + random(0, 40); float tempX; if (j==0) tempX=0; else if (j==(horizDivisions-1)) tempX=width; else { tempX = ((width/horizDivisions) * j) + random(-20, 20); } v1 = new PVector(tempX, tempY); gridXY [j][i] = v1; } } /////// //drawing lines (from gridXY points)////////// for (int m=0; m<overallHorz; m++) { for (int n=0; n<horizDivisions-1; n++) { v2 = new PVector(); v2 = gridXY[n][m]; v3 = new PVector(); v3 = gridXY[n+1][m]; line(v2.x, v2.y, v3.x, v3.y); } } ///////// //***drawing zigzags + straights ***////////////// for (int y=0; y<overallHorz-1; y++) { //for EVERY SECTOR for (int z=0; z<horizDivisions-1; z++) { v4 = new PVector(); v5 = new PVector(); v6 = new PVector(); v7 = new PVector(); v4 = gridXY[z][y]; v5 = gridXY[z+1][y]; v6 = gridXY[z][y+1]; v7 = gridXY[z+1][y+1]; float topSLOPE = (v4.y-v5.y)/(v4.x-v5.x); float bottomSLOPE = (v6.y-v7.y)/(v6.x-v7.x); //mx+b = y; float b1 = v4.y - (topSLOPE*v4.x); float b2 = v6.y - (bottomSLOPE*v6.x); //////choosing zigzags, straights, or none int decision = floor(random(0, 5)); //#0 //*zig zags*// if (decision == 0) { float numSlashes = random(8, 30); for (int g=0; g<numSlashes; g++) { float newX = (random(v4.x, v5.x)); float newX2 = (random(v6.x, v7.x)); float newY = (topSLOPE*newX) + b1; float newY2 = (bottomSLOPE*newX2) + b2; line(newX, newY, newX2, newY2); } } //#1 //*straight lines*// else if (decision == 1) { float numLines = random(5, 18); for (int h=0; h<numLines; h++) { float newX = (random(v4.x, v5.x)); float newY = (topSLOPE*newX) + b1; float newY2 = (bottomSLOPE*newX) + b2; line(newX, newY, newX, newY2); } } //#2 //*blank area*// else { //println("*skip*"); } } } /******/ ////CIRCLES////////********/// int randCircles = floor(random(3, 11)); for (int q=0; q<randCircles; q++) { float randRadius = random(2, 150); ellipse(random(0, width), random(0, height), randRadius, randRadius); } } |
Comments Off on Rothera_alex-13-9-65