* 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)
| 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; |