Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
float ellipse_x;
float ellipse_y;
float easingFactor = 0.1;
   
void setup() {
  size(800, 600); 
  noStroke();  
}
   
void draw() { 
  background(255);
  fill(0);
  float target_x = mouseX;
  float distance_x = target_x - ellipse_x;
  if(abs(distance_x) > 1) {  //check that the absolute value(positive) ofif the distance is greater than 1
    println(distance_x); 
    ellipse_x += distance_x * easingFactor;
  }
     
  float target_y = mouseY;
  float distance_y = target_y - ellipse_y;
  if(abs(distance_y) > 1) {   //check that the absolute value(positive) of the distance is greater than 1
    ellipse_y += distance_y * easingFactor;
  }
  ellipse(ellipse_x, ellipse_y, 60, 60);
}

...