xxxxxxxxxx
void setup() {
// sets up the canvas size
size(250, 250);
// sets background to (255, 255, 255) (R, G, B)
background(255);
}
void draw() {
// noise() takes an argument and generates smooth
// random values in the range (0, 1)
float n = noise(frameCount);
// map() maps n from the (0, 1) range on to
// a range more useful for drawing
float size = map(n, 0, 1, 5, 65);
noStroke();
// mousePressed is true if the mouse is depressed
if (!mousePressed) {
fill(153);
// tell Processing to interpret the arguments
// to rect as indicating the center of the rect
// as opposed to the first corner
rectMode(CENTER);
// draw a rect at the current mouse location
// with size size
rect(mouseX, mouseY, size, size);
} else {
fill(255);
ellipse(mouseX, mouseY, size, size);
}
}