Lerp rate/speed - how to change the number of interpolation steps attached to a slider?

Hey guys, I’ve got a slider and I convert the position of it’s x and y coordinates into an amount from 0 to 1 which I then lerp to result in an animation when you slide from left to right. Is there a way to control the speed of this ie the number of interpolated steps in between? If I simply add a scaling factor, this results in the animation being reached at 0.5 of the slider. I think I’m being quite slow but I really can’t think of any solution to this at the minute. Would appreciate your input.

1 Like


A n example to get you started:

void setup() 
  size(300, 300);

void draw() 
  float div = map(mouseX, 0, width, 0, 1);
  int tmp = int(9*div+1);
  if (frameCount%tmp == 0) x++;
  if (x == width) x = 0;
  stroke(255, 0, 0);  
  point(x, height/2);



1 Like