MCPcopy Create free account
hub / github.com/microsoft/SandDance / cubehelixConvert

Function cubehelixConvert

docs/app/js/sanddance-app.js:128147–128152  ·  view source on GitHub ↗
(o)

Source from the content-addressed store, hash-verified

128145var _mathJs = require("./math.js");
128146var 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;
128147function 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}
128153function cubehelix(h, s, l, opacity) {
128154 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
128155}

Callers 1

cubehelixFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected