Reference lerpColor()

lerpColor()

Blends two colors to find a third color between them.

The amt parameter specifies the amount to interpolate between the two values. 0 is equal to the first color, 0.1 is very near the first color, 0.5 is halfway between the two colors, and so on. Negative numbers are set to 0. Numbers greater than 1 are set to 1. This differs from the behavior of lerp. It's necessary because numbers outside of the interval [0, 1] will produce strange and unexpected colors.

The way that colors are interpolated depends on the current colorMode().

Examples

Syntax

lerpColor(c1, c2, amt)

Parameters

c1
p5.Color:

interpolate from this color (any value created by the color() function).

c2
p5.Color:

interpolate to this color (any value created by the color() function).

amt
Number:

number between 0 and 1.

Returns

p5.Color: interpolated color.
Notice any errors or typos? Please let us know. Please feel free to edit src/color/creating_reading.js and open a pull request!

Related References