void setup( ){
size(300,300);
}
float x=100,y=150;
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 dx=x-200;
float dy=y-150;
float len=sqrt(dx*dx+dy*dy);
x-=dx*(len-100)/len*0.1;
y-=dy*(len-100)/len*0.1;
}
}
void mouseDragged( )
{
x=mouseX;
y=mouseY;
}

沒有留言:
張貼留言