# Smooth animation/interpolation

**URL:** https://discourse.processing.org/t/smooth-animation-interpolation/31623
**Category:** Coding Questions
**Created:** [August 8, 2021, 12:26pm UTC](https://discourse.processing.org/t/smooth-animation-interpolation/31623 "2021-08-08T12:26:00Z")
**Posts on this page:** 1
**Showing post:** 6

<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: [August 19, 2021, 2:44am UTC](https://discourse.processing.org/t/smooth-animation-interpolation/31623/6 "2021-08-19T02:44:30Z")

</div>

> [@anoniim](#):
>
> For linear change, there is the `lerp()` method in Processing `PApplet` for linear interpolation between two values. I wonder if there is a method that could help me implement non-linear interpolation.

@anoniim,

If you are look for non-linear alternatives to the `lerp()` and `map()` Processing built-ins, these are sometimes discussed as “interpolation” but often – especially in animation – called “easing.”

[https://www.febucci.com/assets/uploads/2018/Animation-References-easing-equations.mp4](https://www.febucci.com/assets/uploads/2018/Animation-References-easing-equations.mp4)

Easing forms are often named after the function type of the curve that does the mapping, e.g. linear, quadratic, cubic, sinusoidal, et cetera. There is a good survey of implementing these in Java Processing (for your Kotlin project) in the recent writeup:

[Easing Functions in Processing](https://sighack.com/post/easing-functions-in-processing)

The source code from that writeup is here – it implements map2() and map3():

> <https://github.com/sighack/easing-functions/blob/master/code/easing/easing.pde>

Several past Processing libraries have implemented a collection of easing function that might be worth looking over. Two in particular:

1. [gicentre utils](https://www.gicentre.net/utils/easing), which includes [Ease](https://gicentre.org/utils/reference/org/gicentre/utils/move/Ease.html)
2. the [Ani animation library](http://www.looksgood.de/libraries/Ani/), which is actually an older Processing 2 library from 2015, but implements easing as a full set of classes rather than mapping functions:

> <https://github.com/b-g/Ani/tree/master/src/de/looksgood/ani/easing>
>
> //github.com/b-g/Ani/tree/master/src/de/looksgood/ani/easing

Finally, piecewise interpolation (a.k.a. list-based interpolation) is the same thing based on a segmented path rather than a curve.

- [Varying scale at frameCount - #3 by jeremydouglass](https://discourse.processing.org/t/varying-scale-at-framecount/17896/3)
- [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/smooth-animation-interpolation/31623)._
