mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-04 17:41:23 +01:00
37 lines
838 B
JavaScript
37 lines
838 B
JavaScript
"use strict";
|
|
|
|
// Ice layer renderer - renders ice from data model to SVG
|
|
function drawIce() {
|
|
TIME && console.time("drawIce");
|
|
|
|
// Clear existing ice SVG
|
|
ice.selectAll("*").remove();
|
|
|
|
// Draw glaciers
|
|
pack.ice.glaciers.forEach((glacier, index) => {
|
|
ice
|
|
.append("polygon")
|
|
.attr("points", glacier.points)
|
|
.attr("type", "iceShield")
|
|
.attr("data-index", index)
|
|
.attr("class", "glacier");
|
|
});
|
|
|
|
// Draw icebergs
|
|
pack.ice.icebergs.forEach((iceberg, index) => {
|
|
ice
|
|
.append("polygon")
|
|
.attr("points", iceberg.points)
|
|
.attr("cell", iceberg.cellId)
|
|
.attr("size", iceberg.size)
|
|
.attr("data-index", index)
|
|
.attr("class", "iceberg");
|
|
});
|
|
|
|
TIME && console.timeEnd("drawIce");
|
|
}
|
|
|
|
// Re-render ice layer from data model
|
|
function redrawIce() {
|
|
drawIce();
|
|
}
|