float angle; float radius; float lastX; float lastY; float h; void setup() { size(800,600); colorMode(HSB); background(255); smooth(); angle = 0; radius = 10; lastX = mouseX; lastY = mouseY; h = random(0,255); } void draw() { if (mousePressed && mouseButton == LEFT) { float strength = dist(lastX, lastY, mouseX, mouseY) + 40; float sat = random(63,255); float bright = random(63,255); stroke(h, sat, bright, strength); strokeWeight(strength/100); noFill(); drawline(); angle += PI/20; drawline(); angle += PI/20; drawline(); angle += PI/20; } lastX = mouseX; lastY = mouseY; } void drawline() { float ax = lastX + cos(angle)*radius; float ay = lastY + sin(angle)*radius; float bx = mouseX + cos(angle+PI/2)*radius; float by = mouseY + sin(angle+PI/2)*radius; line(ax, ay, bx, by); } void mousePressed() { if (mouseButton == RIGHT) { // this might be a cool place to toggle between colors? h = random(255); } } void keyPressed() { if (key == 's' || key == 'S') { // save an image save("CE3-drawing" + year() +"-"+ month() +"-"+ day() +"-" + hour() +"-" + minute() + ".png"); } else if (key == ENTER) { h = random(0,255); background(255); } }