// let us remember the last time we clicked the mouse float strength = 0; // Initialization void setup() { size(500,500); // Make the window bigger smooth(); // Make the edges smoother (anti-aliased) background(0,0,0); // Black background strokeWeight(2); // Thicken the lines drawn } // What to do every frame void draw() { if (mousePressed) { // set the strength to high strength = 1; // Choose random red, green, and blue components of the fill and stroke color // also make it a bit transparent fill(random(200,255),random(200,255),random(200,255),100); stroke(random(128,255),random(128,255),random(128,255),100); // pick a random radius and save it away float radius = random(50); // draw the ellipse ellipse(mouseX,mouseY,radius,radius); // draw a line connecting this position to the last one line(mouseX,mouseY,pmouseX,pmouseY); } else { // continue a fading stroke whe the mouse is released, until the strength fades completely if(strength > 0.05) { // Choose random red, green, and blue components of the fill and stroke color // also make it a bit transparent fill(random(200,255),random(200,255),random(200,255),100*strength); stroke(random(128,255),random(128,255),random(128,255),100*strength); // pick a random radius and save it away float radius = random(50); // draw the ellipse ellipse(mouseX,mouseY,radius,radius); // draw a line connecting this position to the last one line(mouseX,mouseY,pmouseX,pmouseY); // decrease the strength strength = strength * 0.95; } } } // START NO NOTES // code used to capture screenshots void keyReleased() { if(key == '`' && !online) save("sketch.png"); }