mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-03-23 23:57:23 +01:00
fix: clean up drawWebGl and drawSvg functions for improved readability
This commit is contained in:
parent
ab7baf83fd
commit
828534ebd9
2 changed files with 15 additions and 131 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue