Skip to content

Interpolation

Interpolation (also known as lerping) allows the blending between two values. Where it really shines is when it is used over time to progressively reach some target value.

A simple implementation looks like this:

// Interpolate from a->b by amount (0..1)
const interpolate = (amount, a, b) => (1-amount) * a + amount * b;

In ixfx it’s found in the Module Numbers module as interpolate .

import { interpolate } from "https://unpkg.com/ixfx/dist/numbers.js";
// Returns the value 50% between 200 and 400 (ie. 300)
interpolate(0.5, 200, 400);

ixfx has custom interpolation for Lines, Points & Colour.