How to use the d3-color.lab function in d3-color

To help you get started, we’ve selected a few d3-color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / d3-color / d3-color-tests.ts View on Github external
cHSL = d3Color.hsl(c);
cHSL = cHSL.brighter();
cHSL = cHSL.brighter(0.2);
cHSL = cHSL.darker();
cHSL = cHSL.darker(0.2);
cRGB = cHSL.rgb();
displayable = cHSL.displayable();
cString = cHSL.toString();
console.log('Channels = (h : %d, s: %d, l: %d)', cHSL.h, cHSL.s, cHSL.l);
console.log('Opacity = %d', cHSL.opacity);

// Signature tests for Lab

let cLab: d3Color.LabColor;

cLab = d3Color.lab(120, 40, 50);
cLab = d3Color.lab(120, 40, 50, 0.5);
cLab = d3Color.lab('steelblue');
cLab = d3Color.lab('rgba(20, 100, 200, 0.5)');
cLab = d3Color.lab(c);
cLab = cLab.brighter();
cLab = cLab.brighter(0.2);
cLab = cLab.darker();
cLab = cLab.darker(0.2);
cRGB = cLab.rgb();
displayable = cLab.displayable();
cString = cLab.toString();
console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b);
console.log('Opacity = %d', cLab.opacity);


// Signature tests for HCL
github DefinitelyTyped / DefinitelyTyped / d3-color / d3-color-tests.ts View on Github external
cHSL = cHSL.brighter(0.2);
cHSL = cHSL.darker();
cHSL = cHSL.darker(0.2);
cRGB = cHSL.rgb();
displayable = cHSL.displayable();
cString = cHSL.toString();
console.log('Channels = (h : %d, s: %d, l: %d)', cHSL.h, cHSL.s, cHSL.l);
console.log('Opacity = %d', cHSL.opacity);

// Signature tests for Lab

let cLab: d3Color.LabColor;

cLab = d3Color.lab(120, 40, 50);
cLab = d3Color.lab(120, 40, 50, 0.5);
cLab = d3Color.lab('steelblue');
cLab = d3Color.lab('rgba(20, 100, 200, 0.5)');
cLab = d3Color.lab(c);
cLab = cLab.brighter();
cLab = cLab.brighter(0.2);
cLab = cLab.darker();
cLab = cLab.darker(0.2);
cRGB = cLab.rgb();
displayable = cLab.displayable();
cString = cLab.toString();
console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b);
console.log('Opacity = %d', cLab.opacity);


// Signature tests for HCL

let cHcl: d3Color.HCLColor;
github DefinitelyTyped / DefinitelyTyped / d3-color / d3-color-tests.ts View on Github external
cHSL = cHSL.darker();
cHSL = cHSL.darker(0.2);
cRGB = cHSL.rgb();
displayable = cHSL.displayable();
cString = cHSL.toString();
console.log('Channels = (h : %d, s: %d, l: %d)', cHSL.h, cHSL.s, cHSL.l);
console.log('Opacity = %d', cHSL.opacity);

// Signature tests for Lab

let cLab: d3Color.LabColor;

cLab = d3Color.lab(120, 40, 50);
cLab = d3Color.lab(120, 40, 50, 0.5);
cLab = d3Color.lab('steelblue');
cLab = d3Color.lab('rgba(20, 100, 200, 0.5)');
cLab = d3Color.lab(c);
cLab = cLab.brighter();
cLab = cLab.brighter(0.2);
cLab = cLab.darker();
cLab = cLab.darker(0.2);
cRGB = cLab.rgb();
displayable = cLab.displayable();
cString = cLab.toString();
console.log('Channels = (l : %d, a: %d, b: %d)', cLab.l, cLab.a, cLab.b);
console.log('Opacity = %d', cLab.opacity);


// Signature tests for HCL

let cHcl: d3Color.HCLColor;
github Evercoder / culori / test / lab2rgb-d50.js View on Github external
fs.readFileSync('./datasets/matlab-lab2rgb-d50.txt', 'utf8').split(/\n/).forEach(line => {
	let values = line.split(/\s+/);
	let l = parseFloat(values[0]), 
		a = parseFloat(values[1]), 
		B = parseFloat(values[2]), 
		r = parseFloat(values[3]), 
		g = parseFloat(values[4]), 
		b = parseFloat(values[5]);
	console.log(`input: L ${l}, a ${a}, b ${B}`);
	console.log(`expected: R ${r}, G ${g}, B ${b}`);
	let d3c = lab2(l, a, B).rgb();
	console.log(`d3-color: R ${ d3c.r / 255 }, G ${ d3c.g / 255 } B ${ d3c.b / 255 }`);

	let c = rgb({ mode: 'lab', l: l, a: a, b: B });
	console.log(`culori:   R ${c.r}, G ${c.g}, B ${c.b}`);
})
github orbiting / styleguide / src / components / TeaserFront / Format.js View on Github external
const Format = ({ children, color, collapsedColor }) => {
  const labColor = lab(color)
  const labCollapsedColor = lab(collapsedColor || color)
  const mixColorStyle =
    collapsedColor &&
    css({
      color:
        labCollapsedColor.l > 50
          ? labCollapsedColor.darker(0.6)
          : labCollapsedColor.brighter(3.0),
      [tUp]: {
        color: labColor.l > 50 ? labColor.darker(2.0) : labColor.brighter(3.0)
      }
    })

  return (
github junkerm / specmate / bundles / specmate-ui-core / webcontent / lib / js / d3 / d3-ng2-service / node_modules / d3-interpolate / src / lab.js View on Github external
export default function lab(start, end) {
  var l = color((start = colorLab(start)).l, (end = colorLab(end)).l),
      a = color(start.a, end.a),
      b = color(start.b, end.b),
      opacity = color(start.opacity, end.opacity);
  return function(t) {
    start.l = l(t);
    start.a = a(t);
    start.b = b(t);
    start.opacity = opacity(t);
    return start + "";
  };
}
github orbiting / publikator-frontend / components / Tree / index.js View on Github external
getColor(hash) {
    if (this.colors.has(hash)) {
      return this.colors.get(hash)
    }
    const { colors } = this.state
    const color = colors(hash)
    let backgroundColor = lab(color)
    backgroundColor.opacity = 0.2
    backgroundColor = backgroundColor.toString()
    let highlightColor = lab(color)
    highlightColor.opacity = 0.3
    highlightColor = highlightColor.toString()
    const res = { color, backgroundColor, highlightColor }
    this.colors.set(hash, res)
    return res
  }
github d3 / d3-interpolate / src / lab.js View on Github external
export default function lab(start, end) {
  var l = color((start = colorLab(start)).l, (end = colorLab(end)).l),
      a = color(start.a, end.a),
      b = color(start.b, end.b),
      opacity = color(start.opacity, end.opacity);
  return function(t) {
    start.l = l(t);
    start.a = a(t);
    start.b = b(t);
    start.opacity = opacity(t);
    return start + "";
  };
}

d3-color

Color spaces! RGB, HSL, Cubehelix, Lab and HCL (Lch).

ISC
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis