MCPcopy Create free account
hub / github.com/breck7/scroll / cubehelixConvert

Function cubehelixConvert

external/.d3.js:3430–3442  ·  view source on GitHub ↗
(o)

Source from the content-addressed store, hash-verified

3428 BC_DA = B$1 * C - D$1 * A;
3429
3430function cubehelixConvert(o) {
3431 if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
3432 if (!(o instanceof Rgb)) o = rgbConvert(o);
3433 var r = o.r / 255,
3434 g = o.g / 255,
3435 b = o.b / 255,
3436 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
3437 bl = b - l,
3438 k = (E * (g - l) - C * bl) / D$1,
3439 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)), // NaN if l=0 or l=1
3440 h = s ? Math.atan2(k, bl) * degrees$2 - 120 : NaN;
3441 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
3442}
3443
3444function cubehelix$3(h, s, l, opacity) {
3445 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);

Callers 1

cubehelix$3Function · 0.85

Calls 1

rgbConvertFunction · 0.85

Tested by

no test coverage detected