今天要畫3x3的圓的啦
ps.這是較麻煩的版本
ps,這是較需動腦但程式比較少的版本
ps.開始變成你想要多少就有多少
ps.現在要讓球放大
程式如下:
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++; ///////放大到跟他直徑一樣時就會停下
}
ps.更多更多!!!!
程式如下:
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; ///////從0開始
}
}
ps.滑鼠所及之處,有點不同
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(0,250,160); ///////達成條件,就變
else fill(255); ////////沒有就,不變
if(dist(mouseX,mouseY,w+x*R,200+w+y*R)<w)fill(255,60,40); //////滑鼠碰到,變色
ellipse(w+x*R,200+w+y*R,RR,RR);
}
}
if(RR<R)RR+=R/30;
}
ps.大家來找碴
void setup()
{
size(300,500);
colorMode(HSB,256); ////////HBS色彩系統,與RGB跟CMYK又有所不同
}
int ansX=1,ansY=2;
int n=3,RR=0;
int H=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(H-10,243,234); ////這裡的H-10就是要讓他有些微改變的啦!!!!
else fill(H,255,255);
if(dist(mouseX,mouseY,w+x*R,200+w+y*R)<w)
{
if(mousePressed && x==ansX && y==ansY)
{
ansX=int (random(n));
ansY=int (random(n));
H+=20;
if(H>256)H=0; //////HBS最大色彩值是256,超過就歸零
}
}
ellipse(w+x*R,200+w+y*R,RR,RR);
}
}
if(RR<R)RR+=R/30;
}







沒有留言:
張貼留言