int leftBounds = 20; int topBounds = 20; float x = 200; float y = 200; int rightBounds = 380; int bottomBounds = 380; int baseMax = 4; int randomMax = 4; int maxLines = 2000; int counter = 0; void setup(){ size(400, 400); colorMode(HSB, 360, 100, 100); background(0,0,100); strokeWeight(1); smooth(); } void draw(){ if(counter < maxLines){ int maxDistance = baseMax * int(random(0, 1) * randomMax); int minDistance = 2; int direction = random(0, 1) < 0.5 ? -1 : 1; float xEnd = x + (cos(counter*0.1) * maxDistance ); direction = random(0, 1) < 0.5 ? -1 : 1; float yEnd = y + (sin(counter*0.1) * maxDistance ); if(xEnd < leftBounds) xEnd = leftBounds; if(xEnd > rightBounds) xEnd = rightBounds; if(yEnd < topBounds) yEnd = topBounds; if(yEnd > bottomBounds) yEnd = bottomBounds; line(x, y, xEnd, yEnd); x = xEnd; y = yEnd; counter++; } else noLoop(); } void keyPressed(){ if(key == 'r'){ loop(); background(0, 0, 100); counter = 0; } if(key =='q'){ saveFrame("p41_Lines10.jpg"); exit(); } }