// Dartmouth CS 2, Winter 2009, Chris Bailey-Kellogg // Notes 1 | Sketch 5 // Based on a sketch by Sharp Hall, http://stereotheism.org/071106/ // Initialization void setup() { size(500,500); // Make the window bigger smooth(); // Make the edges smoother (anti-aliased) background(0,0,0); // Black background frameRate(15); // Slow it down -- 15 frames per second } // What to do every frame void draw() { if (mousePressed) { // Choose random red, green, and blue components of the stroke color // Also make it slightly opaque (200) stroke(random(255),random(255),random(255),200); // Choose random width of the stroke strokeWeight(random(30)); // Now draw a line from the current mouse position to the previous one line(mouseX,mouseY,pmouseX,pmouseY); } // Every fifth frame, draw a square if (frameCount % 5 == 0) { // Random fill color; somewhat more opaque noStroke(); fill(random(0,60),random(30,80),random(80,120),100); // Random position; size 100x100 rect(random(width),random(height), 100,100); } }