function drawTrapezoids({
dimensions,
midPoints,
trapezoids,
gapUV,
stroke,
strokeWidth
}) {
const { marginX, marginY, size, width, height } = dimensions;
const cellSize = size / rows;
const gap = computeGap(cellSize, gapUV);
const s = cellSize - gap;
const line = d3.line().curve(d3.curveLinearClosed);
return midPoints.map(([u, v], i) => {
const cx = math.lerp(
marginX + gap / 2 + s / 2,
width - marginX - gap / 2 - s / 2,
u
);
const cy = math.lerp(
marginY + gap / 2 + s / 2,
height - marginY - gap / 2 - s / 2,
v
);
const trapezoid = trapezoids[i];
const polygon = trapezoid.map(([u, v]) => [
math.lerp(-s / 2, s / 2, u),
math.lerp(-s / 2, s / 2, v)
]);
return htl.svg`<g
transform=${`translate(${cx},${cy})`}
stroke-linejoin="round"
style="filter: url(#foreground-filter)"
>
<path d=${line(
polygon
)} fill="none" stroke=${stroke} stroke-width=${strokeWidth}></path>
</g>`;
});
}