Research Topics/Processing Code share
[과제080419] 함경석
알 수 없는 사용자
2008. 4. 20. 17:28



void setup(){
size(400,400,P3D);
frameRate(100);
}
float i = 0.0; // rotate speed
int r = int(random(255)); // initial RGB value
int g = int(random(255));
int b = int(random(255));
int rt = r;
int gt = g;
int bt = b;
void draw(){
background(255);
fill(r,g,b,100); //setting box color
stroke(r,g,b,100);
// random rgb color and iteration
if(( r >= rt) || (r <= 0)) { // red
rt = r;
r = r + 1;
}
if(( r>= 255) || (r < rt)) {
rt = r;
r = r - 1;
}
if(( g >= gt) || (g <= 0)) { // green
gt = g;
g = g + 1;
}
if(( g>= 255) || (g < gt)) {
gt = g;
g = g - 1;
}
if(( b >= bt) || (b <= 0)) { // blue
bt = b;
b = b + 1;
}
if(( b>= 255) || (b < bt)) {
bt = b;
b = b - 1;
}
i += 0.01;
translate(width/2, height/2 , 0);
rotateY(i);
box(100);
if(i > TWO_PI) {
i = 0.0;
}
}