Skip to content

Instantly share code, notes, and snippets.

@PoignardAzur
Created May 12, 2025 12:11
Show Gist options
  • Save PoignardAzur/7e93ffaad2163f6edcd9b9b4f5f77f6d to your computer and use it in GitHub Desktop.
Save PoignardAzur/7e93ffaad2163f6edcd9b9b4f5f77f6d to your computer and use it in GitHub Desktop.
function generateSVG(N, M, S) {
const rects = [];
for (let y = 0; y < M; y++) {
for (let x = 0; x < N; x++) {
rects.push(`<rect x="${x * S}" y="${y * S}" width="${S}" height="${S}" fill="none" stroke="black" stroke-width="2"/>`);
}
}
const width = N * S;
const height = M * S;
return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}">${rects.join('')}</svg>`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment