data = {
const h = ((image.naturalHeight / image.naturalWidth) * w) | 0,
context = DOM.context2d(w, h, 1);
context.drawImage(image, 0, 0, w, h);
const colors = [],
data = context.getImageData(0, 0, w, h).data;
for (let i = 0; i < data.length; i += 4) {
const c = d3.rgb(data[i] + .001, data[i + 1], data[i + 2]),
hsl = d3.hsl(c),
color = [
Math.sin((hsl.h / 180) * Math.PI),
Math.cos((hsl.h / 180) * Math.PI),
hsl.s,
hsl.l,
c.r,
c.g,
c.b
];
color.c = c;
colors.push(color);
}
return colors;
}