mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
ice drawing with only type on less occuring glaciers
This commit is contained in:
parent
6003dbb111
commit
d1250b4c00
1 changed files with 6 additions and 6 deletions
|
|
@ -27,7 +27,7 @@ function drawIce() {
|
||||||
function redrawIceberg(index) {
|
function redrawIceberg(index) {
|
||||||
TIME && console.time("redrawIceberg");
|
TIME && console.time("redrawIceberg");
|
||||||
const iceberg = pack.ice.icebergs[index];
|
const iceberg = pack.ice.icebergs[index];
|
||||||
let el = ice.selectAll(`.iceberg[data-index="${index}"]`);
|
let el = ice.selectAll(`polygon[data-index="${index}"]:not([type="glacier"])`);
|
||||||
if (!iceberg && !el.empty()) {
|
if (!iceberg && !el.empty()) {
|
||||||
el.remove();
|
el.remove();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -35,7 +35,7 @@ function redrawIceberg(index) {
|
||||||
// Create new element if it doesn't exist
|
// Create new element if it doesn't exist
|
||||||
const polygon = getIcebergHtml(iceberg, index);
|
const polygon = getIcebergHtml(iceberg, index);
|
||||||
ice.node().insertAdjacentHTML("beforeend", polygon);
|
ice.node().insertAdjacentHTML("beforeend", polygon);
|
||||||
el = ice.selectAll(`.iceberg[data-index="${index}"]`);
|
el = ice.selectAll(`polygon[data-index="${index}"]:not([type="glacier"])`);
|
||||||
}
|
}
|
||||||
el.attr("points", iceberg.points);
|
el.attr("points", iceberg.points);
|
||||||
el.attr("transform", iceberg.offset ? `translate(${iceberg.offset[0]},${iceberg.offset[1]})` : null);
|
el.attr("transform", iceberg.offset ? `translate(${iceberg.offset[0]},${iceberg.offset[1]})` : null);
|
||||||
|
|
@ -46,7 +46,7 @@ function redrawIceberg(index) {
|
||||||
function redrawGlacier(index) {
|
function redrawGlacier(index) {
|
||||||
TIME && console.time("redrawGlacier");
|
TIME && console.time("redrawGlacier");
|
||||||
const glacier = pack.ice.glaciers[index];
|
const glacier = pack.ice.glaciers[index];
|
||||||
let el = ice.selectAll(`.glacier[data-index="${index}"]`);
|
let el = ice.selectAll(`polygon[data-index="${index}"][type="glacier"]`);
|
||||||
if (!glacier && !el.empty()) {
|
if (!glacier && !el.empty()) {
|
||||||
el.remove();
|
el.remove();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -54,7 +54,7 @@ function redrawGlacier(index) {
|
||||||
// Create new element if it doesn't exist
|
// Create new element if it doesn't exist
|
||||||
const polygon = getGlacierHtml(glacier, index);
|
const polygon = getGlacierHtml(glacier, index);
|
||||||
ice.node().insertAdjacentHTML("beforeend", polygon);
|
ice.node().insertAdjacentHTML("beforeend", polygon);
|
||||||
el = ice.selectAll(`.glacier[data-index="${index}"]`);
|
el = ice.selectAll(`polygon[data-index="${index}"][type="glacier"]`);
|
||||||
}
|
}
|
||||||
el.attr("points", glacier.points);
|
el.attr("points", glacier.points);
|
||||||
el.attr("transform", glacier.offset ? `translate(${glacier.offset[0]},${glacier.offset[1]})` : null);
|
el.attr("transform", glacier.offset ? `translate(${glacier.offset[0]},${glacier.offset[1]})` : null);
|
||||||
|
|
@ -63,9 +63,9 @@ function redrawGlacier(index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGlacierHtml(glacier, index) {
|
function getGlacierHtml(glacier, index) {
|
||||||
return `<polygon points="${glacier.points}" data-index="${index}" ${glacier.offset ? `transform="translate(${glacier.offset[0]},${glacier.offset[1]})"` : ""} class="glacier"/>`;
|
return `<polygon points="${glacier.points}" type="glacier" data-index="${index}" ${glacier.offset ? `transform="translate(${glacier.offset[0]},${glacier.offset[1]})"` : ""}/>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIcebergHtml(iceberg, index) {
|
function getIcebergHtml(iceberg, index) {
|
||||||
return `<polygon points="${iceberg.points}" data-index="${index}" ${iceberg.offset ? `transform="translate(${iceberg.offset[0]},${iceberg.offset[1]})"` : ""} class="iceberg"/>`;
|
return `<polygon points="${iceberg.points}" data-index="${index}" ${iceberg.offset ? `transform="translate(${iceberg.offset[0]},${iceberg.offset[1]})"` : ""}/>`;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue