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

Function labConvert

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

Source from the content-addressed store, hash-verified

3309 t3 = t1$1 * t1$1 * t1$1;
3310
3311function labConvert(o) {
3312 if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
3313 if (o instanceof Hcl) return hcl2lab(o);
3314 if (!(o instanceof Rgb)) o = rgbConvert(o);
3315 var r = rgb2lrgb(o.r),
3316 g = rgb2lrgb(o.g),
3317 b = rgb2lrgb(o.b),
3318 y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn), x, z;
3319 if (r === g && g === b) x = z = y; else {
3320 x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
3321 z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
3322 }
3323 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
3324}
3325
3326function gray(l, opacity) {
3327 return new Lab(l, 0, 0, opacity == null ? 1 : opacity);

Callers 2

lab$1Function · 0.85
hclConvertFunction · 0.85

Calls 4

hcl2labFunction · 0.85
rgbConvertFunction · 0.85
rgb2lrgbFunction · 0.85
xyz2labFunction · 0.85

Tested by

no test coverage detected