rgbToHSL = ([r, g, b]) => {
let nR = r/255;
let nG = g/255;
let nB = b/255;
let min = Math.min(nR, nG, nB);
let max = Math.max(nR, nG, nB);
let value = max;
let chroma = max - min;
let lightness = (min + max)/2;
let hue = max == 0 ? 0 :
max == nR ? (nG - nB) / chroma :
max == nG ? 2 + (nB - nR) / chroma:
max == nB ? 4 + (nR - nG) / chroma : 0;
let sat = max == 0 ? 0 :
lightness < 0.5 ? chroma/value : chroma/(2 - 2 * lightness);
return [60 * hue, sat * 100, lightness * 100];
}