Comments:
In this recitation, I learned how we can make really cool and interesting animations with the processing. The fact that we can create animation with processing is important because it lays a foundation for the construction of highly interactive projects. Since the world is in a constant state of movement and dynamic, thus animation is an essential part of integrating real-life interaction into our projects. This recitation made me understand that even simple animation can be really interesting and worthy viewing.
One of the most interesting function I use is the random function with keypressed function. This function allows the background to change in a fast frequency while press the keys, thus turning the processing display into a really fascinating and artistic. Other interesting functions I used:
- Rotate
- ColorMode
- Translate
- PopMatrix
- PushMatrix
Codes and Videos of recitation exercise:
Codes:
float angle = 0;
int x;
void setup(){
size(500,500);
}
void draw(){
background(0);
angle = frameCount;
rectMode(CENTER);
pushMatrix();
translate(width/2,height/2);
rotate(radians(angle));
rect(x,0,100,100);
x=0;
popMatrix();
if(mousePressed){
x= 100;
}
if(keyPressed){
background(random(0,255),random(0,255),random(0,255));
pushMatrix();
translate(width/2,height/2);
rotate(radians(angle));
rect(x,0,100,100);
x=0;
popMatrix();
}
}
Videos:
Codes and Videos of Homework:
Codes:
int v = 100;
int speed = 4;
int i = 0;
int j = 0;
int z = 0;
int speedb = 1;
int w = 0;
int h = 0;
int eX;
int eY;
void setup(){
size(600,600);
}
void draw(){
//ellipseMode(CENTER);
background(#FFFFFF);
noFill();
strokeWeight(20);
colorMode(HSB, 100, 100, 100);
stroke(i, j, z);
i = i + speedb ;
j = j + speedb ;
z = z + speedb ;
if (i > 100 | j> 100 | z > 100| i < 0| j < 0| z < 0 ){
speedb = – speedb;
}
ellipse(eX, eY, v, v);
eX = width/2 + w;
eY = height/2 + h;
v = v + speed;
if (v > 280 | v < 80){
speed = -speed;
}
}
void keyPressed() {
if (key == CODED) {
if (keyCode == LEFT){
w = w – 6;
} else if (keyCode == RIGHT) {
w = w + 6;
}
}
if (key == CODED) {
if (keyCode == UP) {
h = h – 6;
}
else if (keyCode == DOWN) {
h = h + 6;
}
}
}
Videos: