{
const svg = d3.create("svg")
.attr("width", 256)
.attr("height", 256);
function hexagon(x, y, r) {
const x1 = x;
const y1 = y - r;
const x2 = x + Math.cos(Math.PI / 6) * r;
const y2 = y - Math.sin(Math.PI / 6) * r;
const x3 = x + Math.cos(Math.PI / 6) * r;
const y3 = y + Math.sin(Math.PI / 6) * r;
const x4 = x;
const y4 = y + r;
const x5 = x - Math.cos(Math.PI / 6) * r;
const y5 = y + Math.sin(Math.PI / 6) * r;
const x6 = x - Math.cos(Math.PI / 6) * r;
const y6 = y - Math.sin(Math.PI / 6) * r;
return `${x1},${y1} ${x2},${y2} ${x3},${y3} ${x4},${y4} ${x5},${y5} ${x6},${y6}`;
}
const filas = 7;
const columnas = 7;
const r = 16;
const dx = Math.cos(Math.PI / 6) * r * 2 * 1.15;
const dy = r * 1.5 * 1.1;
const patternWidth = dx * (columnas - 1) + r * 2;
const patternHeight = dy * (filas - 1) + r * 2;
const offsetX0 = (256 - patternWidth) / 2;
const offsetY0 = (256 - patternHeight) / 2;
for (let row = 0; row < filas; row++) {
for (let col = 0; col < columnas; col++) {
const offsetX = col * dx + (row % 2 === 1 ? dx / 2 : 0);
const offsetY = row * dy;
const strokeWidth = 0.2 + (row / (filas - 1)) * 2.3;
svg.append("polygon")
.attr("points", hexagon(offsetX0 + offsetX, offsetY0 + offsetY, r))
.attr("fill", "white")
.attr("stroke", "black")
.attr("stroke-width", strokeWidth);
}
}
return svg.node();
}