[−][src]Static p5_sys::global::lerpColor
pub static lerpColor: LerpColorInternalType
Blends two colors to find a third color somewhere between them. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first color, 0.1 is very near the first color, 0.5 is halfway in between, etc. An amount below 0 will be treated as 0. Likewise, amounts above 1 will be capped at 1. This is different from the behavior of lerp(), but necessary because otherwise numbers outside the range will produce strange and unexpected colors.
The way that colors are interpolated depends on the current color mode.
Examples
colorMode(RGB); stroke(255); background(51); let from = color(218, 165, 32); let to = color(72, 61, 139); colorMode(RGB); // Try changing to HSB. let interA = lerpColor(from, to, 0.33); let interB = lerpColor(from, to, 0.66); fill(from); rect(10, 20, 20, 60); fill(interA); rect(30, 20, 20, 60); fill(interB); rect(50, 20, 20, 60); fill(to); rect(70, 20, 20, 60);
Parameters
c1
interpolate from this color
c2
interpolate to this color
amt
number between 0 and 1