Interaction Piece

float r;
float g;
float b;
float a;

float x;
float y;
float PrevMouseX;
float PrevMouseY;
void setup() {
frameRate = .1;

size(800,800);
background(255);
}

void draw() {
r = random(255);
g = random(255);
b = random(255);
a = random(255);
x = random(width);
y = random(height);
noStroke();
fill(r, g, b, a);
triangle(x,y,x,y+80,x+80,y+80);

if(PrevMouseX!=mouseX || PrevMouseY!=mouseY){
triangle(mouseX,mouseY,mouseX,mouseY+80,mouseX+80,mouseY+80);
fill(0);
}
PrevMouseX=mouseX;
PrevMouseY=mouseY;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s