viewof svg = {
const cols = 17;
const rows = 17;
const size = 20;
const width = cols * size;
const height = rows * size;
const svg = DOM.svg(width, height);
const context = d3.select(svg);
const colorX = d3.scaleLinear().domain([0, cols - 1]).range(["green", "red"]);
const colorY = d3.scaleLinear().domain([0, rows - 1]).range(["black", "yellow"]);
for (let y = 0; y < rows; y++) {
for (let x = 0; x < cols; x++) {
const cx = x * size + size / 2;
const cy = y * size + size / 2;
const c1 = d3.color(colorX(x));
const c2 = d3.color(colorY(y));
const mixed = d3.rgb(
(c1.r + c2.r) / 2,
(c1.g + c2.g) / 2,
(c1.b + c2.b) / 2
);
const final = d3.rgb(mixed);
context.append("circle")
.attr("cx", cx)
.attr("cy", cy)
.attr("r", 6)
.attr("fill", mixed);
}
}
return svg;
}