Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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;
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;
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}`);
})
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 (
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 + "";
};
}
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
}
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 + "";
};
}