Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processing Lecture.3 Loop and animation lbg@dongseo.ac.kr.

Similar presentations


Presentation on theme: "Processing Lecture.3 Loop and animation lbg@dongseo.ac.kr."— Presentation transcript:

1 Processing Lecture.3 Loop and animation

2 INDEX Loop and animation Do it : Simple example Homework

3 Homework solution

4 Lecture plan What is Processing + Simple drawing
Mouse + Keyboard input event Loop and animation Processing + Kinect Flash + Kinect

5 Loop and Animation

6 Loop and animation for() while()
for(initialize value; condition; calculate); Ex) for(int i=0; i<5; i++) while() while(condition) Ex) while(i==10) Initialize Process Condition Quit Yes No Process Condition Quit Yes No

7 Loop and animation for() void setup(){ size(200, 200);
background(255); } void draw(){ int endLegs = 150; int x = 50, y = 50, spacing = 30, len = 50; stroke(0); for(x = 50; x <= endLegs; x=x+spacing) { line(x,y,x,y+len);

8 Loop and animation while() void setup(){ size(200, 200);
background(255); } void draw(){ int endLegs = 150; int x = 50, y = 50, spacing = 30, len = 50; stroke(0); while(x <= endLegs){ line(x,y,x,y+len); x=x+spacing;

9 Do it : Simple example

10 Do it: Simple example(Loop)
void setup(){ size(200, 200); background(255); } void draw(){ stroke(0); for(int i = 10; i < 200; i+=10){ line(0, i, 200, i);

11 Do it: Simple example(Loop)
void setup(){ size(200, 200); background(255); } void draw(){ stroke(0); for(int i = 200; i > 0; i-=20){ fill(i); ellipse(100, 100, i, i);

12 Do it: Simple example(Loop)
void setup(){ size(255, 200); background(255); } void draw(){ stroke(0); int x = 0; for(int c = 255; c > 0; c-=15){ fill(c); rect(x, 0, x+15, height); x=x+15;

13 Do it: Simple example(Animate)
Animation int x = 0; int y = 0; void setup( ){ size(100, 100); noStroke( ); } void draw( ){ background(0); rect(x, 0, 5, height); x=x+1; if(x>width) x=0; rect(0, y, width, 5); y=y+1; if(y>height) y=0;

14 Do it: Simple example(Animate)
Animation int x = 0; int y = 0; void setup( ){ size(100, 100); noStroke( ); } void draw( ){ background(0); rect(x, y, 10, 10); x+=5; if(x>=width){ x=0; y+=5; if(y>=height){ y=0;

15 Homework

16 Homework

17 Q& A


Download ppt "Processing Lecture.3 Loop and animation lbg@dongseo.ac.kr."

Similar presentations


Ads by Google