| 128145 | var _mathJs = require("./math.js"); |
| 128146 | var A = -0.14861, B = 1.78277, C = -0.29227, D = -0.90649, E = 1.97294, ED = E * D, EB = E * B, BC_DA = B * C - D * A; |
| 128147 | function cubehelixConvert(o) { |
| 128148 | if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); |
| 128149 | if (!(o instanceof (0, _colorJs.Rgb))) o = (0, _colorJs.rgbConvert)(o); |
| 128150 | var r = o.r / 255, g = o.g / 255, b = o.b / 255, l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB), bl = b - l, k = (E * (g - l) - C * bl) / D, s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), h = s ? Math.atan2(k, bl) * (0, _mathJs.degrees) - 120 : NaN; |
| 128151 | return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); |
| 128152 | } |
| 128153 | function cubehelix(h, s, l, opacity) { |
| 128154 | return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); |
| 128155 | } |