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

Function hclConvert

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

Source from the content-addressed store, hash-verified

3378}
3379
3380function hclConvert(o) {
3381 if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
3382 if (!(o instanceof Lab)) o = labConvert(o);
3383 if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0 < o.l && o.l < 100 ? 0 : NaN, o.l, o.opacity);
3384 var h = Math.atan2(o.b, o.a) * degrees$2;
3385 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
3386}
3387
3388function lch(l, c, h, opacity) {
3389 return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);

Callers 2

lchFunction · 0.85
hcl$2Function · 0.85

Calls 1

labConvertFunction · 0.85

Tested by

no test coverage detected