运行结果
代码部分
void setup(){
size(600,600);
radius = 0.5*width/float(num_side+1);
}
int num_side = 10;
float t = 0.0;
float dt = 0.01;
float x,y,osc,radius;
float rateRatio=0.75;
void draw(){
t = t + dt;
background(255);
for(int i = 0; i<num_side; i++){
for(int j = 0; j<num_side; j++){
fill(0);
x=float(j)/float(num_side);
y=float(i)/float(num_side);
osc = radius*(sin(TWO_PI * (y+t))+cos(TWO_PI * (x+t)));
ellipse(2*(radius+i*radius),2*(radius+j*radius),osc,osc);
}
}
for(int i = 0;i<num_side;i++){
for(int j = 0;j<num_side;j++){
x = float(j)/float(num_side);
y = float(i)/float(num_side);
fill(255);
osc = 25*(sin(TWO_PI*(y-rateRatio*t))+cos(TWO_PI*(x-rateRatio*t)));
ellipse(2*(radius+i*radius),2*(radius+j*radius),osc,osc);
}
}
}