MCPcopy
hub / github.com/KilledByAPixel/LittleJS / lerp

Method lerp

src/engineMath.js:966–976  ·  view source on GitHub ↗

Returns a new color that is p percent between this and the color passed in * @param {Color} c - other color * @param {number} percent * @return {Color}

(c, percent)

Source from the content-addressed store, hash-verified

964 * @param {number} percent
965 * @return {Color} */
966 lerp(c, percent)
967 {
968 ASSERT_COLOR_VALID(c);
969 ASSERT_NUMBER_VALID(percent);
970 const p = clamp(percent);
971 return new Color(
972 c.r*p + this.r*(1-p),
973 c.g*p + this.g*(1-p),
974 c.b*p + this.b*(1-p),
975 c.a*p + this.a*(1-p));
976 }
977
978 /** Sets this color given a hue, saturation, lightness, and alpha
979 * @param {number} [h] - hue

Callers 15

math.test.mjsFile · 0.45
debugOverlapFunction · 0.45
randColorFunction · 0.45
randColorMethod · 0.45
interpMethod · 0.45
renderMethod · 0.45
updateMethod · 0.45
renderMethod · 0.45
constructorMethod · 0.45
gameRenderFunction · 0.45
gameRenderFunction · 0.45
collideWithObjectMethod · 0.45

Calls 3

ASSERT_COLOR_VALIDFunction · 0.85
ASSERT_NUMBER_VALIDFunction · 0.85
clampFunction · 0.85

Tested by

no test coverage detected