# Varying scale at frameCount

**URL:** <https://discourse.processing.org/t/varying-scale-at-framecount/17896>\
**Category:** Coding Questions\
**Created:** [February 17, 2020, 11:07pm UTC](https://discourse.processing.org/t/varying-scale-at-framecount/17896 "2020-02-17T23:07:30Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [February 26, 2020, 8:41am UTC](https://discourse.processing.org/t/varying-scale-at-framecount/17896/3 "2020-02-26T08:41:30Z")

</div>

> [@ChrisHaz3ll](#):
>
> An example would be at 0 - 400 I’d want scale to be 1.5, and then 401 - 500 I’d want scale to transition up to 2 in a smooth way.

One method is to use list-based interpolations

```auto
float lerps( float amt, float... vals) {
  if(vals.length==1){ return vals[0]; }
  float unit = 1.0/(vals.length-1);
  return lerp(vals[floor(amt / unit)], vals[ceil(amt / unit)], amt%unit/unit);
}

```

So my time / vals will be like this:

0 1.5  
100 1.5  
200 1.5  
300 1.5  
400 1.5  
500 2.0

So my amt, which ranges 0-1.0, will be `time/500.0` and my vals will be `new float[] {1.5, 1.5, 1.5, 1.5, 1.5, 2.0}` With that, lerps() will return the correct results for e.g. time = 450 (1.75)

For more, see:

- [List-based interpolations - Processing 2.x and 3.x Forum](https://forum.processing.org/two/discussion/25310/list-based-interpolations)

---

_[View the full topic](https://discourse.processing.org/t/varying-scale-at-framecount/17896)._
