Function
hueToRgba
(p: number, q: number, tp: number)
Source from the content-addressed store, hash-verified
| 49 | * Converts a color value from HSL to RGBA. |
| 50 | */ |
| 51 | const hueToRgba = (p: number, q: number, tp: number) => { |
| 52 | let t = tp; |
| 53 | |
| 54 | if (t < 0) { |
| 55 | t += 1; |
| 56 | } |
| 57 | |
| 58 | if (t > 1) { |
| 59 | t -= 1; |
| 60 | } |
| 61 | |
| 62 | if (t < 1 / 6) { |
| 63 | return p + (q - p) * 6 * t; |
| 64 | } |
| 65 | |
| 66 | if (t < 1 / 2) { |
| 67 | return q; |
| 68 | } |
| 69 | |
| 70 | if (t < 2 / 3) { |
| 71 | return p + (q - p) * (2 / 3 - t) * 6; |
| 72 | } |
| 73 | |
| 74 | return p; |
| 75 | }; |
| 76 | |
| 77 | const round = (n: number) => { |
| 78 | return Math.round(n * 100) / 100; |
Tested by
no test coverage detected