Recitation 6: Processing Animation by Ryan

My work

float angle = 0.1;
boolean big = true;
int i = 1;
int size = 200;

void setup(){
size(1000,1000,P3D);
background(255);
}

void draw(){
if (i < 15 && big == true){
size += 10;
i ++;
if( i == 15){
big = false;
}
}
if ( i > 0 && big == false){
size -= 10;
i --;
if( i == 0){
big = true;
}
}
background(255);
//strokeWeight(random(0.1,1));
translate(mouseX,mouseY);
rotateY(angle+=0.01);
rotateX(angle += 0.01);
rotateZ(angle += 0.01);
noFill();
stroke(mouseX,mouseY,mouseX/(mouseY+1));
sphere(size-100);
stroke(0);
box(size+100);
}

Additional homework

boolean big = true;
int i = 1;
int size = 350;

void setup(){
size(600,600);
}

void draw(){
if (i < 40 && big == true){
size -= 5;
i ++;
if( i == 40){
big = false;
}
}
if ( i > 0 && big == false){
size += 5;
i --;
if( i == 0){
big = true;
}
}
colorMode(RGB, 255);
background(255);
noFill();
colorMode(HSB,350);
stroke(size - 100,size,100);
strokeWeight(20);
float x = mouseX;
float y = mouseY;
if(x<=size/2+10){
x = size/2+10;
}else if (x>=(590-size/2)){
x = (590-size/2);
}else{
x = mouseX;
}
if(y<=size/2+10){
y = size/2+10;
}else if (y>=(590-size/2)){
y = (590-size/2);
}else{
y = mouseY;
}
circle(x,y,size);
}

What I have learned is basically how to do the animation based on if condition, it is powerful to acheive many effects, and it is easy for me to understand as I have learned python and java before. So there are no difficulty programing these, what I need to know are the specific functions to draw shapes. Those that interest me are:

circle(x,y,radius)

colorMode()

box()

translate()

scale()

rotate()

P3D

sphere()

Leave a Reply