DIY cloth continued -INTERACTIVE code

The previous piece I made with code was a simple composition of lines and shapes.

1.png

Code:

size(1000,700);
background(193, 218, 255);
rect(600,100,200,100);
line(200,600,800,650);
fill(255, 212, 0);
arc(350,300,500,450,0,PI+QUARTER_PI,OPEN);
noFill();
quad(550,150,700,230,730,490,570,400);
line(500,150,800,800);
quad(500,650,800,650,700,600,500,650);
quad(140,500,350,400,320,620,100,550);

For the continuing piece, I made the shapes change colors by the mouse dragging.

If no action is taken, the shapes are colored with black. If mouse is dragged, the shapes gradually change color from black to white.

2-1.png

2-2.png

 

Code:
// Drag (click and hold) your mouse across the
// image to change the value of the shapes

int value = 0;

void setup() {
size(1000,700);
background(193,218,255);
}
void draw() {
fill(value);
rect(600,100,200,100);
arc(350,300,500,450,0,PI+QUARTER_PI,OPEN);
quad(500,650,800,650,700,600,500,650);
quad(140,500,350,400,320,620,100,550);
noFill();
line(200,600,800,650);
line(500,150,800,800);
}
void mouseDragged()
{
value = value + 5;
if (value > 255) {
value = 0;
}
}

From writing this code, I learned that there is two types of code, which are: static code and dynamic code.

I had hard time trying to figure out the error in my code, but I eventually solved it. I learned that dynamic code is a code when you use to make your piece beyond just a static image (interactive code or moving/motion code).

 

Heewon Kim

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