fix: clean up drawWebGl and drawSvg functions for improved readability

This commit is contained in:
Azgaar 2026-03-11 00:21:48 +01:00
parent ab7baf83fd
commit 828534ebd9
2 changed files with 15 additions and 131 deletions

View file

@ -233,8 +233,6 @@ function renderFrame(): void {
}
function drawWebGl(icons: ReliefIcon[], parentEl: HTMLElement): void {
parentEl.innerHTML = "";
parentEl.dataset.mode = "webGL";
const set = parentEl.getAttribute("set") || "simple";
if (ensureRenderer()) {
@ -248,12 +246,12 @@ function drawWebGl(icons: ReliefIcon[], parentEl: HTMLElement): void {
}
function drawSvg(icons: ReliefIcon[], parentEl: HTMLElement): void {
const html = icons.map(
(r) =>
`<use href="${r.href}" data-id="${r.i}" x="${r.x}" y="${r.y}" width="${r.s}" height="${r.s}"/>`,
);
parentEl.innerHTML = html.join("");
parentEl.dataset.mode = "svg";
parentEl.innerHTML = icons
.map(
(r) =>
`<use href="${r.href}" data-id="${r.i}" x="${r.x}" y="${r.y}" width="${r.s}" height="${r.s}"/>`,
)
.join("");
}
window.drawRelief = (
@ -262,6 +260,9 @@ window.drawRelief = (
) => {
if (!parentEl) throw new Error("Relief: parent element not found");
parentEl.innerHTML = "";
parentEl.dataset.mode = "webGL";
const icons = pack.relief?.length ? pack.relief : generateRelief();
if (!icons.length) return;