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

**URL:** <https://discourse.processing.org/t/lerp-rate-speed-how-to-change-the-number-of-interpolation-steps-attached-to-a-slider/21234>\
**Category:** Coding Questions\
**Created:** [May 24, 2020, 10:56am UTC](https://discourse.processing.org/t/lerp-rate-speed-how-to-change-the-number-of-interpolation-steps-attached-to-a-slider/21234 "2020-05-24T10:56:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkk16](https://avatars.discourse-cdn.com/v4/letter/r/a6a055/32.png) [@rkk16](https://discourse.processing.org/u/rkk16)\
**Post date:** [May 24, 2020, 10:56am UTC](https://discourse.processing.org/t/lerp-rate-speed-how-to-change-the-number-of-interpolation-steps-attached-to-a-slider/21234/1 "2020-05-24T10:56:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 24, 2020, 12:49pm UTC](https://discourse.processing.org/t/lerp-rate-speed-how-to-change-the-number-of-interpolation-steps-attached-to-a-slider/21234/2 "2020-05-24T12:49:11Z")

</div>

Hello,

A n example to get you started:

```auto
void setup() 
	{
  size(300, 300);
	}

void draw() 
	{
  background(0);
  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);  
  strokeWeight(3);  
  point(x, height/2);
	}

```

[https://processing.org/reference/modulo.html](https://processing.org/reference/modulo.html)

`:)`
