Skip to main content

Function: lerpRgb()

function lerpRgb(
from: Rgb,
to: Rgb,
t: number
): Rgb;

Defined in: math.ts:35

Component-wise colour interpolation.

Deliberately naive: this mixes in whatever space the caller authored in (sRGB, by convention throughout this package) rather than converting to linear and back. A sky fading from blue to black through a slightly dark blue is what an author authoring in sRGB expects to see, and the conversion would cost an allocation per channel per frame for a difference nobody has asked for. An app that wants a physically correct mix can author its own midpoint preset and transition through it.

Parameters

ParameterType
fromRgb
toRgb
tnumber

Returns

Rgb