MadelineGannon-13-9-65
______________________________________________________________________________________
____________________________________________________________________________
void setup() { size(600, 600); smooth(); background(255); frameRate(.5); stroke(0); noFill(); } void draw() { background(255); rect(0,0,width-1,height-1); // (1) create distorted grid // make x-intervals List xInt = new ArrayList(); int x = 0; xInt.add(x); while (x < width-20) { int randX = int(random(20, width/4+20)); x += randX; xInt.add(x); } // make initial y-intervals List yInt = new ArrayList(); int y = 20; while (y height) int randY = int(random(20, height/8+20)); if (randY > height) y = height; else y += randY; yInt.add(y); } // store the distorted grid List grid = new ArrayList(); for (int j=0; j<yInt.size(); j++){ for (int i=0; i<xInt.size(); i++){ // get the current and previous point PVector pt1 = grid.get(j*xInt.size()+i-1); PVector pt2 = grid.get(j*xInt.size()+i); line(pt1.x,pt1.y,pt2.x,pt2.y); } } } // (2) add verticle elements // for each grid cell for (int col=0; col<yInt.size()-1; col++){ for (int row=1; row<xInt.size(); row++){ // get cell points PVector s1 = grid.get(col*xInt.size()+row-1); PVector e1 = grid.get(col*xInt.size()+row); PVector s2 = grid.get((col+1)*xInt.size()+row-1); PVector e2 = grid.get((col+1)*xInt.size()+row); // percentage (k) of a line segment: // x0 = (1-k)*start.x + k*end.x // y0 = (1-k)*start.y + k*end.y // create randomly spaced line if (ceil(e1.y % 3) == 2){ for (int i=0; i<10; i++){ float k = random(0,1); float x0 = (1-k)*s1.x + k*e1.x; float y0 = (1-k)*s1.y + k*e1.y; float x1 = (1-k)*s2.x + k*e2.x; float y1 = (1-k)*s2.y + k*e2.y; line(x0,y0,x1,y1); } } // create randomly spaced,random endpoints if (ceil(e1.y % 3) == 3){ for (int i=0; i<20; i++){ float k = random(0,1); float x0 = (1-k)*s1.x + k*e1.x; float y0 = (1-k)*s1.y + k*e1.y; k = random(0,1); float x1 = (1-k)*s2.x + k*e2.x; float y1 = (1-k)*s2.y + k*e2.y; line(x0,y0,x1,y1); } } } } // (3) create circles for (int c=0; c < xInt.size(); c++){ int margin = 52; float radius = random(2,125); ellipseMode(CENTER); ellipse(random(margin,width-margin),random(margin,height-margin),radius,radius); } } |
Comments Off on MadelineGannon-13-9-65