2012年3月11日 星期日

Home Work 5-2



From this project I have learnt how to animate a picture using different colour circles.


int num = 50;
int col =255;
int[] x = new int[num];
int[] y = new int[num];
int[] e = new int[col];
int[] f = new int[col];
int[] g= new int [col];
void setup() {
size (300, 200);
noStroke();
smooth();
fill(255,20,200);
}
void draw() {
background(0);
// Shift the values to the right
for (int i = num-1; i > 0; i--) {
x[i] = x[i-1];
y[i] = y[i-1];
}
// Add the new values to the beginning of the array
x[0] = mouseX;
y[0] = mouseY;
// Draw the circles
for (int i = 0; i < num; i++) {
fill (random (255), random (255), random (255));
ellipse(x[i], y[i], i/2.0, i/2.0);
}
}

沒有留言:

張貼留言