Moving Shapes

Here is the code of an assignment for Interactive Authoring that deals with moving shapes, both interactive and non-interactive.

boolean click;
boolean button;
float r;
float g;
float b;
float a;
float circleX;
float circleY;
float circleW = 0;
float circleH = 0;
float rectX;
float rectY;
float rectW;
float rectH;
float triX1;
float triX2;
float triY1;
float triY2;

void setup(){

size(720,480);
smooth();

}

void draw(){

background(0,g,b);
frameRate(24);

r = random(255);
g = random(255);
b = random(255);
a = (100);
circleX = 360;
circleY = 240;
rectX = random(width);
rectY = random(height);
rectW = random(200);
rectH = random(200);
triX1 = 720;
triY1 = 480;
triX2 = 0;
triY2 = 480;

//rectangle
noStroke();
fill(r,0,b);
rect(rectX,rectY,rectW,rectH);

//triangles
fill(0,113);
triangle(0,0,0,480,triX1,triY1);
fill(255,113);
triangle(720,0,720,480,triX2,triY2);

//circle
noStroke();
fill(r,g,b);
ellipse(mouseX,mouseY,circleW,circleH);

if (click == true){

circleW = circleW + 2;
circleH = circleH + 2;

}

//black screen with text
if (button == true){
frameRate(2);
noStroke();
fill(0);
rect(0,0,720,480);
textSize(50);
fill(r,g,b);
text(“error”,596,473);
}

}

void mousePressed(){
click = true;
}

void keyPressed(){
button = true;
}

void keyReleased(){
button = false;
}

Advertisements
This entry was posted in Non-Timebased and tagged , . Bookmark the permalink.

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