{const svg = d3.create("svg")
.attr("width", 256)
.attr("height", 270);
const hexagonData1 = [];
const hexagonData2 = [];
const strokeWidthScale = d3.scaleLinear()
.domain([0, 256])
.range([0.5, 5]);
const r=20
const stepx = 2*r;
const stepy = Math.sqrt(3) * r;
for (let x = stepx; x <= 256; x += stepx) {
for (let y = stepy; y <= 256; y += stepy) {
hexagonData1.push({ points: hexagon(x, 2*y, r), fillColor: "white", borderColor: "black",strokeWidth: strokeWidthScale(y) });
}
}
for (let x = stepx; x <= 256; x += stepx) {
for (let y = stepy; y <= 256; y += stepy) {
hexagonData2.push({ points: hexagon(x-stepx/2, 2*y-stepy, r), fillColor: "white", borderColor: "black" ,strokeWidth: strokeWidthScale(y)});
}
}
const allHexagonData = hexagonData1.concat(hexagonData2);
svg.selectAll("polygon")
.data(allHexagonData)
.enter()
.append("polygon")
.attr("points", d => d.points)
.attr("fill", d => d.fillColor)
.attr("stroke", d => d.borderColor)
.attr("stroke-width", d => d.strokeWidth);
return svg.node();
}