lerp() / Reference

  • size(400, 400);
    float a = 80;
    float b = 320;
    float c = lerp(a, b, .8);
    float d = lerp(a, b, .20);
    float e = lerp(a, b, .32);
    beginShape(POINTS);
    vertex(a, 200);
    vertex(b, 200);
    vertex(c, 200);
    vertex(d, 200);
    vertex(e, 200);
    endShape();
    Image output for example 1
  • size(400, 400);
    int x1 = 60;
    int y1 = 40;
    int x2 = 320;
    int y2 = 360;
    line(x1, y1, x2, y2);
    for (int i = 0; i <= 40; i++) {
      float x = lerp(x1, x2, i/40.0) + 40;
      float y = lerp(y1, y2, i/40.0);
      point(x, y);
    }
    Image output for example 2