今天一開始要做一個圓圈化圓、線段連接的程式
接著使他能伸縮滑動
float x=100,y=150;
float dx = x-200;
void draw()
{
background(#002966);
stroke(#b7efff);
line(x,y,200,150);
fill(#b7efff);
ellipse(x,y,13,13);
ellipse(200,150,13,13);
if(! mousePressed)
{
float w = x-200;
float dy = y-150;
float len=sqrt(dx*dx+dy*dy);
x -= w*(len-100)/len*0.1;
y -= dy*(len-100)/len*0.1;
}
}
void mouseDragged()
{
x=mouseX;y=mouseY;
}
然後寫了一個圓圈會跟著滑鼠動
改動 圓圈與滑鼠保持100距離




沒有留言:
張貼留言