MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / hue2rgb

Function hue2rgb

app/util/blockies.js:267–274  ·  view source on GitHub ↗

* Converts an HSL color value to RGB. Conversion formula * adapted from http://en.wikipedia.org/wiki/HSL_color_space. * Assumes h, s, and l are contained in the set [0, 1] and * returns r, g, and b in the set [0, 255]. * * @param {number} h The hue * @param {number} s

(p, q, t)

Source from the content-addressed store, hash-verified

265 */
266
267 function hue2rgb(p, q, t) {
268 if (t < 0) t += 1;
269 if (t > 1) t -= 1;
270 if (t < 1 / 6) return p + (q - p) * 6 * t;
271 if (t < 1 / 2) return q;
272 if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
273 return p;
274 }
275
276 function hsl2rgb(h, s, l) {
277 let r, g, b;

Callers 1

hsl2rgbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected