function colorFromImage(ctx) {
return function colorFromCell(bool, columnIndex, rowIndex) {
let hue = 0
let saturation = 0
let lightness = bool ? 0 : 100
if (ctx) {
let [r, g, b] = ctx.getImageData(columnIndex, rowIndex, 1, 1).data
let [_hue, _saturation, _lightness] = rgbToHue(r, g, b)
if (Number.isNaN(_hue)) {
hue = 0
} else {
hue = _hue
saturation = Math.min(_saturation * 500, 100)
lightness = bool ? 25 : 85
}
}
return [hue, saturation, lightness]
}
}