Interactive Sketch

I made my sketch interactive by having the lines on the bottom half move in a looped motion and also the background turns red when the mouse is pressed.

 

Code:

int end = -440;
int start = 360;

int end2 = -650;
int start2 = 650;

void setup(){
size(600, 600);
background(255);
noStroke();
fill(0);
}

void draw(){
background(255);

pushMatrix();
translate(width/2, height/2);
rotate(PI/3.0);

if(mousePressed == true){
background( 255, 0, 0 );
strokeWeight( 10 );
line(mouseX,mouseY,50,50);
}

for (int i = start; i > end; i-=40){
rect(-50, i, 500, 16);
}
//rect(-50, 360, 500, 16);
//rect(-50, 320, 500, 16);
//rect(-50, 280, 500, 16);
//rect(-50, 240, 500, 16);
//rect(-50, 200, 500, 16);
//rect(-50, 160, 500, 16);
//rect(-50, 120, 500, 16);
//rect(-50, 80, 500, 16);
//rect(-50, 40, 500, 16);
//rect(-50, 0, 500, 16);
//rect(-50, -40, 500, 16);
//rect(-50, -80, 500, 16);
//rect(-50, -120, 500, 16);
//rect(-50, -160, 500, 16);
//rect(-50, -200, 500, 16);
//rect(-50, -240, 500, 16);
//rect(-50, -280, 500, 16);
//rect(-50, -320, 500, 16);
//rect(-50, -360, 500, 16);

translate(width/-2, height/-6);
rotate(PI/2.0);
for (int i = start2; i > end2; i-=50){
rect(-300, i, 1000, 10);
}

//rect(-300, -650, 1000, 10);
//rect(-400, -600, 1000, 10);
//rect(-300, -550, 1000, 10);
//rect(-300, -500, 1000, 10);
//rect(-400, -450, 1000, 10);
//rect(-300, -400, 1000, 10);
//rect(-400, -350, 1000, 10);
//rect(-300, -300, 1000, 10);
//rect(-300, -250, 1000, 10);
//rect(-400, -200, 1000, 10);
//rect(-300, -150, 1000, 10);
//rect(-300, -100, 1000, 10);
//rect(-400, -50, 1000, 10);
//rect(-300, 0, 1000, 10);
//rect(-400, 50, 1000, 10);
//rect(-300, 100, 1000, 10);
popMatrix();
start++;
end++;
println (start);
if ( start > 400){
start -= 40;
end -= 40;
}

}

 

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