{
const svg = d3.create("svg")
.attr("width", 600)
.attr("height", 400);
const size = 20;
const spacingX = 7;
const spacingY = 7;
const h = size * Math.sqrt(3) / 2;
for (let row = 0; row < 16; row++) {
for (let col = 0; col < 32; col++) {
const x = col * ((size + spacingX) / 2);
const y = row * (h + spacingY);
const up = (row + col) % 2 === 0;
const points = up
? [[x, y + h], [x + size / 2, y], [x + size, y + h]]
: [[x, y], [x + size / 2, y + h], [x + size, y]];
svg.append("polygon")
.attr("points", points.map(p => p.join(",")).join(" "))
.attr("fill", up ? "yellow": "none")
.attr("stroke", up ? "blue" : "red")
.attr("stroke-width", 2);
}
}
return svg.node();
}