
size(300,500);
ellipse(50,200+50,100,100);
ellipse(50+100,200+50,100,100);
ellipse(50+100+100,200+50,100,100);
ellipse(50,200+50+100,100,100);
ellipse(50+100,200+50+100,100,100);
ellipse(50+100+100,200+50+100,100,100);
ellipse(50,200+50+100+100,100,100);
ellipse(50+100,200+50+100+100,100,100);
ellipse(50+100+100,200+50+100+100,100,100);
2.圓圈縮放

void setup()
{
size(300,500);
}
int n=5;
int r=300/n,w=r/2,rr=0;
void draw()
{
for(int y=0;y<n;y++)
{
for(int x=0;x<n;x++)
{
ellipse(w+x*r,200+w+y*r,rr,rr);
}
}
if(rr<r)rr++;
}
3.圓圈遞增

void setup()
{
size(300,500);
}
int n=3,rr=0;
void draw()
{
background(0);
int r=300/n,w=r/2;
for(int y=0;y<n;y++)
{
for(int x=0;x<n;x++)
{
ellipse(w+x*r,200+w+y*r,rr,rr);
}
}
if(rr<r)rr+=r/30;
else
{
n++;
rr=0;
}
4.選的圓圈會變紅色

void setup()
{
size(300,500);
}
int ansx=1,ansy=2;
int n=3,rr=0;
void draw()
{
background(0);
int r=300/n,w=r/2;
for(int y=0;y<n;y++)
{
for(int x=0;x<n;x++)
{
if(x==ansx&&y==ansy)fill(128);
else fill(255);
if(dist(mouseX,mouseY,w+x*r,200+w+y*r)<w)fill(255,0,0);
ellipse(w+x*r,200+w+y*r,rr,rr);
}
}
if(rr<r)rr+=r/30;
沒有留言:
張貼留言