float counter = 0.0; float speed = 0.3; int x = 0; //Initial code by TheCodingTrain Drop[] drops = new Drop[200]; // array of drop objects Drop2[] drops2 = new Drop2[200]; void setup() { size(900, 900); // size of the window for (int i = 0; i < drops.length; i++) { // we create the drops drops[i] = new Drop(); drops2[i] = new Drop2(); } } void draw() { //background(0); fill(0,20); rect(0,0,width,height); for (int i = 0; i < drops.length; i++) { drops[i].fall(); // sets the shape and speed of drop drops[i].show(); // render drop } for (int i = 0; i width || counter<0 ) { speed = -speed; } // if (x < 600) { // line(x, 0, x, 1); // x = x + 1; //} else { // exit(); // //noLoop(); //} // saveFrame("frames/line-####.png"); } class Drop { float x; // x postion of drop float y; // y position of drop float z; // z position of drop , determines whether the drop is far or near float len; // length of the drop float yspeed; // speed of te drop //near means closer to the screen , ie the higher the z value ,closer the drop is to the screen. Drop() { x = random(width); // random x position ie width because anywhere along the width of screen y = random(-500, -50); // random y position, negative values because drop first begins off screen to give a realistic effect z = random(0, 20); // z value is to give a perspective view , farther and nearer drops effect len = map(z, 0, 20, 10, 20); // if z is near then drop is longer yspeed = map(z, 0, 20, 1, 20); // if z is near drop is faster } void fall() { // function to determine the speed and shape of the drop y = y + yspeed; // increment y position to give the effect of falling float grav = map(z, 0, 20, 0, 0.2); // if z is near then gravity on drop is more yspeed = yspeed + grav; // speed increases as gravity acts on the drop if (y > height) { // repositions the drop after it has 'disappeared' from screen y = random(-200, -100); yspeed = map(z, 0, 20, 4, 10); } } void show() { // function to render the drop onto the screen float thick = map(z, 0, 20, 1, 3); //if z is near , drop is more thicker strokeWeight(thick); // weight of the drop stroke(100, 100, 255); line(x, y, x, y+len); // draws the line with two points } } class Drop2 { float x; // x postion of drop float y; // y position of drop float z; // z position of drop , determines whether the drop is far or near float len; // length of the drop float yspeed; // speed of te drop //near means closer to the screen , ie the higher the z value ,closer the drop is to the screen. Drop2() { x = random(width); // random x position ie width because anywhere along the width of screen y = random(-500, -50); // random y position, negative values because drop first begins off screen to give a realistic effect z = random(0, 20); // z value is to give a perspective view , farther and nearer drops effect len = map(z, 0, 45, 50, 90); // if z is near then drop is longer yspeed = map(z, 0, 40, 10, 100); // if z is near drop is faster } void fall() { // function to determine the speed and shape of the drop y = y + yspeed; // increment y position to give the effect of falling float grav = map(z, 0, 20, 0, 0.2); // if z is near then gravity on drop is more yspeed = yspeed + grav; // speed increases as gravity acts on the drop if (y > height) { // repositions the drop after it has 'disappeared' from screen y = random(-200, -100); yspeed = map(z, 0, 20, 4, 10); } } void show() { // function to render the drop onto the screen float thick = map(z, 0, 15, 1, 1); //if z is near , drop is more thicker strokeWeight(thick); // weight of the drop stroke(85, 51, 82); // purple color line(x, y, x, y+len); // draws the line with two points } }