function drawCells(ctx, { colors: { R, G, B, M}, nx, ny }) {
const H = ctx.canvas.height, W = ctx.canvas.width;
const sx = W / nx, sy = H / ny;
const im = ctx.getImageData(0, 0, W, H);
const data = new Uint32Array(im.data.buffer);
for (let i = 0; i < H; i++) for (let j = 0; j < W; j++) {
const ty = i / (H - 1), tx = j / (W - 1);
const mr = Array.from({ length: 3 }, (_, i) => lerp(M[i],R[i],ty));
const bg = Array.from({ length: 3 }, (_, i) => lerp(B[i],G[i],ty));
let [r, g, b] = Array.from({ length: 3 }, (_, i) => lerp(mr[i],bg[i],tx));
if (((i / sy | 0) + (j / sx | 0)) % 2 == 0)
r *= 1.08, g *= 1.08, b *= 1.08;
data[i * W + j] = (0xff << 24) | (b << 16) | (g << 8) | r;
}
ctx.putImageData(im, 0, 0);
for (let i = 1; i < 10; i++) for (let j = 1; j < 10; j++) {
ctx.beginPath();
ctx.arc(i * sx, j * sy, 1.5 * window.devicePixelRatio, 0, 2 * Math.PI, false);
ctx.fillStyle = 'white';
ctx.fill();
ctx.closePath();
}
}