void setup() { size(600, 600); background(100); frameRate(15); } float paintDripChance = 0.12; int paintDripNum = 0; int paintDripMaxNum = 40; float[] paintDripsX = new float[paintDripMaxNum]; // The location of the drips float[] paintDripsY = new float[paintDripMaxNum]; float[] paintDripsVel = new float[paintDripMaxNum]; // The velocity of the drips void mouseDragged() { // Draw the main stroke stroke(255); strokeWeight(15); // strokeCap(PROJECT); line (pmouseX, pmouseY, mouseX, mouseY); // Paint drip generation if (random(1) < paintDripChance) { paintDripNum = int(random(paintDripMaxNum)); paintDripsX[paintDripNum] = mouseX; paintDripsY[paintDripNum] = mouseY; paintDripsVel[paintDripNum] = 1.5; // Initial velocity for drip // ellipse (paintDripsX[paintDripNum], paintDripsY[paintDripNum], 30, 30); } } void mouseReleased() { //paintDripsX[2] = 2.0; //println(paintDripsX); //println(paintDripsY); } void draw() { // Fade out the old paint noStroke(); fill(0, 1); rect(0, 0, width, height); //Paint drip travel for(int i = paintDripMaxNum -1; i > 0; i--) { noStroke(); fill(255); ellipse(paintDripsX[i], paintDripsY[i], constrain(-paintDripsVel[i] * 0.8 + 8, 0, 10), paintDripsVel[i]+10); paintDripsY[i] = paintDripsY[i] + paintDripsVel[i]; // Move the drip down paintDripsVel[i] = constrain(paintDripsVel[i] * random(0.6, 1.4), 0, 10); // Modify the velocity of drip if(paintDripsVel[i] < 0.2) { // Check if the drip can be stopped paintDripsY[i] = -30; paintDripsX[i] = 0; } if(paintDripsY[i] > height) { // Check if drip reaches the bottom of the screen paintDripsY[i] = 0; } if(paintDripsX[i] == 0) { // Check for drips on the edge of screen paintDripsX[i] = -20; } } }