mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-05 10:01:24 +01:00
refactor: streamline ice generation process and clean up rendering functions
This commit is contained in:
parent
89d27f8e4c
commit
d1e40b6277
3 changed files with 10 additions and 31 deletions
|
|
@ -22,14 +22,6 @@ function drawIce() {
|
|||
ice.html(html);
|
||||
|
||||
TIME && console.timeEnd("drawIce");
|
||||
|
||||
function getGlacierHtml(glacier, index) {
|
||||
return `<polygon points="${glacier.points}" type="iceShield" data-index="${index}" ${glacier.offset ? `transform="translate(${glacier.offset[0]},${glacier.offset[1]})"` : ""} class="glacier"/>`;
|
||||
}
|
||||
|
||||
function getIcebergHtml(iceberg, index) {
|
||||
return `<polygon points="${iceberg.points}" cell="${iceberg.cellId}" size="${iceberg.size}" data-index="${index}" ${iceberg.offset ? `transform="translate(${iceberg.offset[0]},${iceberg.offset[1]})"` : ""} class="iceberg"/>`;
|
||||
}
|
||||
}
|
||||
|
||||
function redrawIceberg(index) {
|
||||
|
|
@ -46,15 +38,9 @@ function redrawIceberg(index) {
|
|||
el = ice.selectAll(`.iceberg[data-index="${index}"]`);
|
||||
}
|
||||
el.attr("points", iceberg.points);
|
||||
el.attr("size", iceberg.size);
|
||||
el.attr("cell", iceberg.cellId);
|
||||
el.attr("transform", iceberg.offset ? `translate(${iceberg.offset[0]},${iceberg.offset[1]})` : null);
|
||||
}
|
||||
TIME && console.timeEnd("redrawIceberg");
|
||||
|
||||
function getIcebergHtml(iceberg, index) {
|
||||
return `<polygon points="${iceberg.points}" cell="${iceberg.cellId}" size="${iceberg.size}" data-index="${index}" ${iceberg.offset ? `transform="translate(${iceberg.offset[0]},${iceberg.offset[1]})"` : ""} class="iceberg"/>`;
|
||||
}
|
||||
}
|
||||
|
||||
function redrawGlacier(index) {
|
||||
|
|
@ -74,13 +60,12 @@ function redrawGlacier(index) {
|
|||
el.attr("transform", glacier.offset ? `translate(${glacier.offset[0]},${glacier.offset[1]})` : null);
|
||||
}
|
||||
TIME && console.timeEnd("redrawGlacier");
|
||||
|
||||
function getGlacierHtml(glacier, index) {
|
||||
return `<polygon points="${glacier.points}" type="iceShield" data-index="${index}" ${glacier.offset ? `transform="translate(${glacier.offset[0]},${glacier.offset[1]})"` : ""} class="glacier"/>`;
|
||||
}
|
||||
}
|
||||
|
||||
// Re-render ice layer from data model
|
||||
function redrawIce() {
|
||||
drawIce();
|
||||
function getGlacierHtml(glacier, index) {
|
||||
return `<polygon points="${glacier.points}" data-index="${index}" ${glacier.offset ? `transform="translate(${glacier.offset[0]},${glacier.offset[1]})"` : ""} class="glacier"/>`;
|
||||
}
|
||||
|
||||
function getIcebergHtml(iceberg, index) {
|
||||
return `<polygon points="${iceberg.points}" data-index="${index}" ${iceberg.offset ? `transform="translate(${iceberg.offset[0]},${iceberg.offset[1]})"` : ""} class="iceberg"/>`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue