//Randomized lines //Nick Ferro Sept 12 2015 //should have used a function for the loop int x = 50; float y = 50; int spacing = 10; //space between lines float len = 300; // length of lines int endLegs = 350; int state = 0; //trigger state for randomization void setup(){ size(400,400); background(200); frameRate(10); stroke(0); while (x <=endLegs) { //does initial randomization on startup y = random(40,100); line (x,y,x,y+len); x = x + spacing; len = random(250,310); } } void draw(){ if (state == 1) { //will redraw if r is pressed background(200); // reset background x = 50; //reset where the lines draw from while (x <=endLegs) { //draws lines y = random(40,100); line (x,y,x,y+len); x = x + spacing; len = random(250,310); } state = 0; //resets trigger state, set to 1 here for constant randomization } } void keyPressed() { if (key == 'r'){ state = 1; } }