MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / hzvToRGB

Function hzvToRGB

libraries/p5.js:8211–8226  ·  view source on GitHub ↗
(hue, zest, val)

Source from the content-addressed store, hash-verified

8209
8210 // Implement projection (project onto green by default).
8211 var hzvToRGB = function(hue, zest, val) {
8212 if (hue < 0) { // Hue must wrap to allow projection onto red and blue.
8213 hue += 6;
8214 } else if (hue >= 6) {
8215 hue -= 6;
8216 }
8217 if (hue < 1) { // Red to yellow (increasing green).
8218 return (zest + (val - zest) * hue);
8219 } else if (hue < 3) { // Yellow to cyan (greatest green).
8220 return val;
8221 } else if (hue < 4) { // Cyan to blue (decreasing green).
8222 return (zest + (val - zest) * (4 - hue));
8223 } else { // Blue to red (least green).
8224 return zest;
8225 }
8226 };
8227
8228 // Perform projections, offsetting hue as necessary.
8229 RGBA = [hzvToRGB(hue + 2, zest, val),

Callers 1

p5.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected