{
const dividend = n;
const wScale = 2;
const h = 80;
const w = steps * wScale;
const c = DOM.context2d(w, h, 1);
c.canvas.style.maxWidth = '100%';
c.fillStyle = `#fff`;
c.fillRect(0,0,w,h);
for(let x = 0; x < steps; x++) {
const digits = (n/(x+1)).toFixed(Math.min(100,decimals)).split('.').pop().split('');
const a = avg(digits) / 9;
c.fillStyle = `hsl(0,0%,${(1-a)*100|0}%)`;
c.fillRect(x * wScale, h - h * a, wScale, h);
}
return c.canvas;
function avg(arr) {
return sum(arr) / arr.length;
}
function sum(arr) {
let s = 0;
for(let v of arr) s += +v;
return s;
}
}