< 454 Home

In this assignment we will build upon the previous concepts and techniques but introduce responsiveness. I hesitate to use the word interactive if only because the programs we are writing are so simple they are merely responding to our actions, not interacting with us. But then, that’s what all programs do essentially. So, using similar but more sophisticated code, create a sketch of random or intentional shapes. To those shapes add an element of responsiveness such as color changing, moving, appearing/disappearing, size changing etc. I’ll write more on this shortly.

Here’s a basic example from class:

// set up the sketch
void setup () {
size(1280, 720);
background(255);
smooth();
}

// create a variable that serves as our array selector
int colorIndex = 0;

//build an a array of colors to choose from
color[] colorPicker = { #b40000, #0ab51a };

//draw a point and constantly check the mouse's Y position
void draw () {
//clear the background
background(255);
// make the stroke color one of the colors from the array by choosing one of its index numbers
stroke(colorPicker[colorIndex]);
strokeWeight(100);
point(100, 200);

//check mouse position
if (mouseY < height/2) { colorIndex = 0; } else { colorIndex = 1; } }