Changing Shapes

This image below is just a screenshot of the animation. In the animation, various shapes go through various changes and movements across the screen.

screen-shot-2016-09-08-at-1-32-52-pm

Code:

float circleX = 0;
float circleY = 0;
float circleW = 50;
float circleH = 100;
float circleStroke = 255;
float circleFill = 0;
float change = 0.25;

// Rectangle ——————————————

float rectX = 500;
float rectY = 0;
float rectW = 25;
float rectH = 50;

float r = random(255);
float g = random(255);
float b = random(255);

float grow = 2;
float move = 1;
float colorChange = 0.5;

// Triangle ——————————————

float triA = 100;
float triB = 50;

float triC = 150;
float triD = 300;

float triE = 30;
float triF = 50;

float animate = 0.75;

// Sliding Rectangles ——————————————

float rect1 = 0;
float rect2 = 240;
float slide = 2;

float rect3 = -100;
float rect4 = 100;
float slide2 = 5;

float rect5 = 720;
float rect6 = 300;
float slide3 = 1;

float rect7 = -25;
float rect8 = 275;
float slide4 = 2.5;

float rect9 = 730;
float rect10 = 50;
float slide5 = 4;
void setup() {
size(720,480);
smooth();
}

void draw() {
background(220,110,220);
stroke(circleStroke);
fill(circleFill);
ellipse(circleX,circleY,circleW,circleH);

circleX = circleX + change;
circleY = circleY + change;
circleW = circleW + change;
circleH = circleH – change;
circleStroke = circleStroke – change;
circleFill = circleFill + change;

//Rectangle ——————————————

stroke(r,g,b);
fill(r,g,b);
rect(rectX,rectY,rectW,rectH);

rectX = rectX – move;
rectY = rectY + move;
rectW = rectW + grow;
rectH = rectH + grow;
r = r + colorChange;
g = g + colorChange;
b = b + colorChange;

// Triangle ——————————————

stroke(255,240,0);
fill(0,50,100);
triangle(triA,triB,triC,triD,triE,triF);

triA = triA + animate;
triB = triB + animate;
triC = triC + animate;
triD = triD – animate;
triE = triE + animate;
triF = triF – animate;

// Sliding Rectangles ——————————————

stroke(200,10,50);
fill(250,130,200);
rect(rect1,rect2,50,20);
rect(rect3,rect4,50,20);
rect(rect5,rect6,50,20);
rect(rect7,rect8,50,20);
rect(rect9,rect10,50,20);

rect1 = rect1 + slide;
rect3 = rect3 + slide2;
rect5 = rect5 – slide3;
rect7 = rect7 + slide4;
rect9 = rect9 – slide5;

}

Advertisements
This entry was posted in Interactive, Time Based 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