打开Processing,Ctrl+R运行.

 

运行效果 : 

 Processing 闪烁的圆  动画效果_i++Processing 闪烁的圆  动画效果_i++_02

class myRect {
float x,y;
float r,a;//banjing secai bianhua
myRect(float x, float y, float r,float a) {
this.x = x;
this.y = y;
this.r = r;
this.a = a;
}
void chang(){
this.a += 0.02;
}
void display() {
stroke(255);
fill(120-120*cos(a), 20 + 20 * tan(a), 255 + 255*sin(a));
circle(x,y,r);
}


void display2() {
stroke(255);
fill(127+127*sin(a));
circle(x,y,r);
}

}

myRect [][]d;
int n=10,m=10;

void setup() {
size(240, 240);
d = new myRect[n][m];
for(int i = 0; i<n; i++) {
for(int j = 0; j<m; j++) {
d[i][j] = new myRect((i+1)*20,(j+1)*20,20,(i+1)+(j+1));
}
}
}
int value=0,aa=0,bb=0;
void mouseClicked() {
if(value == 0) {
value = 1;
}else {
value=0;
}
}
void draw() {
background(0);
for(int i = aa; i<n; i++) {
for(int j = bb; j<m; j++) {
d[i][j].chang();
if(value == 1)
d[i][j].display();
else
d[i][j].display2();
}
}
}