- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name | ### lerp()
Examples |
    float a = 20;
    float b = 80;
    float c = lerp(a, b, .2);
    float d = lerp(a, b, .5);
    float e = lerp(a, b, .8);
    beginShape(POINTS);
    vertex(a, 50);
    vertex(b, 50);
    vertex(c, 50);
    vertex(d, 50);
    vertex(e, 50);
    endShape();
    int x1 = 15;
    int y1 = 10;
    int x2 = 80;
    int y2 = 90;
    line(x1, y1, x2, y2);
    for (int i = 0; i <= 10; i++) {
      float x = lerp(x1, x2, i/10.0) + 10;
      float y = lerp(y1, y2, i/10.0);
      point(x, y);
    }
Description | Calculates a number between two numbers at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. The lerp function is convenient for creating motion along a straight path and for drawing dotted lines.
Syntax |
    lerp(start, stop, amt)
Parameters |
start | float: first value
stop | float: second value
amt | float: float between 0.0 and 1.0
Returns | float
Related | curvePoint() bezierPoint() lerp() lerpColor()

Updated on July 4, 2018 11:56:42am EDT