int segment = 6;
float centerX;
float centerY;
int recursionLevel = 3;
void setup(){
size(600,600);
background(0);
stroke(255);
centerX = height/2;
centerY = width/2;
}
void draw(){
background(0);
// radius = dist(centerX, centerY, mouseX, mouseY);
radius = 50;
pushMatrix();
translate(centerX, centerY);
rotate(frameCount / 50.0);
spiral(0,0,radius,segment, recursionLevel);
popMatrix();
}
void spiral(float x_c,float y_c, float r, int segm, int level){
level -= 1;
noFill();
ellipse(x_c,y_c,2*r,2*r);
for(int i =0; i
float y = y_c+sin(i*2*PI/segm)*r;
point(x,y);
ellipse(x,y,2*r,2*r);
if(level>0){
spiral(x,y,r,segm, level);
}
}
}
EX: 創造一個陣列,讓每個物件旋轉。
沒有留言:
張貼留言