Processing Lecture.3 Loop and animation lbg@dongseo.ac.kr
INDEX Loop and animation Do it : Simple example Homework
Homework solution
Lecture plan What is Processing + Simple drawing Mouse + Keyboard input event Loop and animation Processing + Kinect Flash + Kinect
Loop and Animation
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
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);
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;
Do it : Simple example
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);
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);
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;
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;
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;
Homework
Homework
Q& A