(o)
| 2453 | return new Hsl(h, s, l, a); |
| 2454 | } |
| 2455 | function hslConvert(o) { |
| 2456 | if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); |
| 2457 | if (!(o instanceof Color)) o = color(o); |
| 2458 | if (!o) return new Hsl; |
| 2459 | if (o instanceof Hsl) return o; |
| 2460 | o = o.rgb(); |
| 2461 | var r = o.r / 255, g = o.g / 255, b = o.b / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), h = NaN, s = max - min, l = (max + min) / 2; |
| 2462 | if (s) { |
| 2463 | if (r === max) h = (g - b) / s + (g < b) * 6; |
| 2464 | else if (g === max) h = (b - r) / s + 2; |
| 2465 | else h = (r - g) / s + 4; |
| 2466 | s /= l < 0.5 ? max + min : 2 - max - min; |
| 2467 | h *= 60; |
| 2468 | } else s = l > 0 && l < 1 ? 0 : h; |
| 2469 | return new Hsl(h, s, l, o.opacity); |
| 2470 | } |
| 2471 | function hsl(h, s, l, opacity) { |
| 2472 | return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); |
| 2473 | } |
no test coverage detected