mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
delete rendered rivers on layer off
This commit is contained in:
parent
d5b2e7ed14
commit
d9d349f3a1
3 changed files with 30 additions and 21 deletions
|
|
@ -1444,18 +1444,26 @@ function toggleTexture(event) {
|
|||
function toggleRivers(event) {
|
||||
if (!layerIsOn("toggleRivers")) {
|
||||
turnButtonOn("toggleRivers");
|
||||
$("#rivers").fadeIn();
|
||||
drawRivers();
|
||||
if (event && isCtrlClick(event)) editStyle("rivers");
|
||||
} else {
|
||||
if (event && isCtrlClick(event)) {
|
||||
editStyle("rivers");
|
||||
return;
|
||||
}
|
||||
$("#rivers").fadeOut();
|
||||
if (event && isCtrlClick(event)) return editStyle("rivers");
|
||||
rivers.selectAll("*").remove();
|
||||
turnButtonOff("toggleRivers");
|
||||
}
|
||||
}
|
||||
|
||||
function drawRivers() {
|
||||
const riverPaths = pack.rivers.map(river => {
|
||||
const riverMeandered = Rivers.addMeandering(river.cells, 0.5, river.points);
|
||||
const widthFactor = river.widthFactor || 1;
|
||||
const startingWidth = river.startingWidth || 0;
|
||||
const [path] = Rivers.getRiverPath(riverMeandered, widthFactor, startingWidth);
|
||||
return [path, river.i];
|
||||
});
|
||||
rivers.html(riverPaths.map(d => `<path id="river${d[1]}" d="${d[0]}"/>`).join(""));
|
||||
}
|
||||
|
||||
function toggleRoutes(event) {
|
||||
if (!layerIsOn("toggleRoutes")) {
|
||||
turnButtonOn("toggleRoutes");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue