Practicing Array.
this program will draw ellipses with color.
the scale, location and color of the ellipses will gradually but randomly change.
int[] circle = {100, 120, 30, 90};
float[] colorManager = new float[3];
void setup(){
 size(200, 200);
 initialColor();
}
void draw(){
 for(int i=0; i<=3; i++){
   circle[i] += random(-1,2);
 }
 for(int i=0; i<=2; i++){
   colorManager[i] += random(-2,2);
   if ((colorManager[i]>255)||(colorManager[i]<0)){
     initialColor();
   }
 }
 fill(colorManager[0],colorManager[1],colorManager[2]);
 ellipse(circle[0],circle[1],circle[2],circle[3]);
}
void initialColor(){
 for(int i=0; i<=2; i++){
   colorManager[i] = random(255);
 }
}
0 件のコメント:
コメントを投稿