function row_pic(n) {
let row_pic = Plot.plot({
width: 800,
height: 100,
margin: 0,
x: { domain: [0, 8] },
y: { domain: [0, 1] },
marks: [
Plot.rect(d3.range(1, 10, 2), {
x1: (d) => d,
x2: (d) => d + 1,
y1: 0,
y2: 1,
fill: "#ddd",
stroke: "#ddd"
}),
Plot.line(
[
[0, 0],
[8, 0],
[8, 1],
[0, 1],
[0, 0]
],
{ stroke: "#ccc" }
)
]
});
let matches = rows[n].matchAll(/K/g);
let match_result = matches.next();
while (!match_result.done) {
d3.select(row_pic)
.append("g")
.attr(
"transform",
`translate(${row_pic
.scale("x")
.apply(match_result.value.index)}) scale(2.2)`
)
.append(() => svg`${king}`);
match_result = matches.next();
}
return row_pic;
}