lerpColor()

Color / Creating & Reading

Description

Calculates a color between two colors at a specific increment.

Syntax

color lerpColor(color c1, color c2, float t)

Parameters

NameTypeDescription
c1colorinterpolate from this color
c2colorinterpolate to this color
tfloatbetween 0.0 and 1.0

Returns

color

Related

Under the Hood

From Processing.h:

color lerpColor(color c1, color c2, float t);

Under the Hood

From Processing.cpp:

color PApplet::lerpColor(color c1, color c2, float t) { unsigned int v1 = c1.value; unsigned int v2 = c2.value; int r1 = (v1 >> 16) & 0xFF, r2 = (v2 >> 16) & 0xFF; int g1 = (v1 >> 8) & 0xFF, g2 = (v2 >> 8) & 0xFF; int b1 = v1 & 0xFF, b2 = v2 & 0xFF; int a1 = (v1 >> 24) & 0xFF, a2 = (v2 >> 24) & 0xFF; return colorVal( (int)(r1 + t * (r2 - r1)), (int)(g1 + t * (g2 - g1)), (int)(b1 + t * (b2 - b1)), (int)(a1 + t * (a2 - a1)) ); }