Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var checkColor = function (lab, options) {
const color = chroma.lab(lab)
const hcl = color.hcl()
const rgb = color.rgb()
const compLab = chroma.rgb(rgb).lab()
const labTolerance = 2
return (
hcl[0] >= options.hueMin &&
hcl[0] <= options.hueMax &&
hcl[1] >= options.chromaMin &&
hcl[1] <= options.chromaMax &&
hcl[2] >= options.lightMin &&
hcl[2] <= options.lightMax &&
compLab[0] >= (lab[0] - labTolerance) &&
compLab[0] <= (lab[0] + labTolerance) &&
compLab[1] >= (lab[1] - labTolerance) &&
compLab[1] <= (lab[1] + labTolerance) &&
compLab[2] >= (lab[2] - labTolerance) &&
compLab[2] <= (lab[2] + labTolerance)
)
const colorArray = colorStyles.map(style => {
const child = children
.find(child => get(child, 'styles.fill') === style.id)
if (!child) return
const [ fill = {} ] = child.fills || []
const { r, g, b, a } = fill.color
const rgb = [ r, g, b ].map(n => n * 255)
const color = chroma.rgb(rgb)
return {
id: style.id,
name: style.name,
value: color.hex()
}
})
.filter(Boolean)
const Project = (node) => {
const {
r,
g,
b,
a
} = node.backgroundColor;
const rgb = [r, g, b].map(n => n * 255);
const colorHex = chroma.rgb(rgb).hex();
return {
name: node.name,
background: colorHex,
id: node.id
}
}