grid = (sideLength, cellLength) => {
const magicOffset = 0.5;
const className = (tick) => {
if ((tick === magicOffset) || (tick === (sideLength + magicOffset))) {
return "outer-grid-line";
} else {
return "inner-grid-line";
}
}
const verticalLine = (x) =>
`<line class="${className(x)}" x1="${x}" y1="${magicOffset}" x2="${x}" y2="${sideLength + magicOffset}" />`;
const horizontalLine = (y) =>
`<line class="${className(y)}" x1="${magicOffset}" y1="${y}" x2="${sideLength + magicOffset}" y2="${y}" />`;
let grid = "";
for (let tick = magicOffset; tick <= (sideLength + magicOffset); tick += cellLength) {
grid += verticalLine(tick);
grid += horizontalLine(tick);
}
return grid;
}