mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2026-02-06 10:31:23 +01:00
refactor: drawCells
This commit is contained in:
parent
bfc83e8f7b
commit
289620615f
1 changed files with 4 additions and 9 deletions
|
|
@ -364,22 +364,17 @@ function toggleCells(event) {
|
||||||
drawCells();
|
drawCells();
|
||||||
if (event && isCtrlClick(event)) editStyle("cells");
|
if (event && isCtrlClick(event)) editStyle("cells");
|
||||||
} else {
|
} else {
|
||||||
if (event && isCtrlClick(event)) {
|
if (event && isCtrlClick(event)) return editStyle("cells");
|
||||||
editStyle("cells");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cells.selectAll("path").remove();
|
cells.selectAll("path").remove();
|
||||||
turnButtonOff("toggleCells");
|
turnButtonOff("toggleCells");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawCells() {
|
function drawCells() {
|
||||||
cells.selectAll("path").remove();
|
const cells = customization === 1 ? grid.cells.i : pack.cells.i;
|
||||||
const data = customization === 1 ? grid.cells.i : pack.cells.i;
|
|
||||||
const polygon = customization === 1 ? getGridPolygon : getPackPolygon;
|
const polygon = customization === 1 ? getGridPolygon : getPackPolygon;
|
||||||
let path = "";
|
const paths = Array.from(cells).map(i => "M" + polygon(i));
|
||||||
data.forEach(i => (path += "M" + polygon(i)));
|
byId("cells").innerHTML = `<path d="${paths.join("")}" />`;
|
||||||
cells.append("path").attr("d", path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleIce(event) {
|
function toggleIce(event) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue