UNPKG

@mui/x-charts-vendor

Version:

Vendored dependencies for MUI X Charts.

60 lines (59 loc) 2.06 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.Cubehelix = Cubehelix; exports.default = cubehelix; var _define = _interopRequireWildcard(require("./define.js")); var _color = require("./color.js"); var _math = require("./math.js"); 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; function cubehelixConvert(o) { if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity); if (!(o instanceof _color.Rgb)) o = (0, _color.rgbConvert)(o); 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)), // NaN if l=0 or l=1 h = s ? Math.atan2(k, bl) * _math.degrees - 120 : NaN; return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity); } function cubehelix(h, s, l, opacity) { return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity); } function Cubehelix(h, s, l, opacity) { this.h = +h; this.s = +s; this.l = +l; this.opacity = +opacity; } (0, _define.default)(Cubehelix, cubehelix, (0, _define.extend)(_color.Color, { brighter(k) { k = k == null ? _color.brighter : Math.pow(_color.brighter, k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, darker(k) { k = k == null ? _color.darker : Math.pow(_color.darker, k); return new Cubehelix(this.h, this.s, this.l * k, this.opacity); }, rgb() { var h = isNaN(this.h) ? 0 : (this.h + 120) * _math.radians, l = +this.l, a = isNaN(this.s) ? 0 : this.s * l * (1 - l), cosh = Math.cos(h), sinh = Math.sin(h); return new _color.Rgb(255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity); } }));