(o)
| 3206 | } |
| 3207 | |
| 3208 | function hslConvert(o) { |
| 3209 | if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity); |
| 3210 | if (!(o instanceof Color)) o = color(o); |
| 3211 | if (!o) return new Hsl; |
| 3212 | if (o instanceof Hsl) return o; |
| 3213 | o = o.rgb(); |
| 3214 | var r = o.r / 255, |
| 3215 | g = o.g / 255, |
| 3216 | b = o.b / 255, |
| 3217 | min = Math.min(r, g, b), |
| 3218 | max = Math.max(r, g, b), |
| 3219 | h = NaN, |
| 3220 | s = max - min, |
| 3221 | l = (max + min) / 2; |
| 3222 | if (s) { |
| 3223 | if (r === max) h = (g - b) / s + (g < b) * 6; |
| 3224 | else if (g === max) h = (b - r) / s + 2; |
| 3225 | else h = (r - g) / s + 4; |
| 3226 | s /= l < 0.5 ? max + min : 2 - max - min; |
| 3227 | h *= 60; |
| 3228 | } else { |
| 3229 | s = l > 0 && l < 1 ? 0 : h; |
| 3230 | } |
| 3231 | return new Hsl(h, s, l, o.opacity); |
| 3232 | } |
| 3233 | |
| 3234 | function hsl$2(h, s, l, opacity) { |
| 3235 | return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity); |
no test coverage detected