2020年6月19日 星期五

week17


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(250,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;
 }

沒有留言:

張貼留言