From 240c77ebf2958508e3cb5e692a62185dd0f9c7ad Mon Sep 17 00:00:00 2001 From: b3autydata Date: Sun, 7 Oct 2018 13:57:09 +0200 Subject: [PATCH] expanded cell density range, added spread customization option --- index.html | 12 +++++++++++- script.js | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 755d9893..a68ae605 100644 --- a/index.html +++ b/index.html @@ -385,12 +385,22 @@ Map cells density - + 1 + + + Spread distance + + + + + 1 + + diff --git a/script.js b/script.js index abd3f6ba..3f096a2d 100644 --- a/script.js +++ b/script.js @@ -92,6 +92,7 @@ function fantasyMap() { let elSelected; let autoResize = true; let graphSize; + let cellsSpread; let cells = []; let land = []; let riversData = []; @@ -338,6 +339,12 @@ function fantasyMap() { } else { graphSize = +sizeInput.value; } + if (localStorage.getItem("cellsSpread")) { + cellsSpread = localStorage.getItem("cellsSpread"); + cellsSpreadInput.value = cellsSpreadOutput.value = cellsSpread; + } else { + cellsSpread = +cellsSpreadInput.value; + } if (localStorage.getItem("template")) { templateInput.value = localStorage.getItem("template"); lockTemplateInput.setAttribute("data-locked", 1); @@ -394,6 +401,7 @@ function fantasyMap() { mapHeightInput.value = window.innerHeight; changeMapSize(); graphSize = sizeInput.value = sizeOutput.value = 1; + cellsSpread = cellsSpreadInput.value = cellsSpreadOutput.value = 1; $("#options i[class^='icon-lock']").each(function() { this.setAttribute("data-locked", 0); this.className = "icon-lock-open"; @@ -7140,7 +7148,7 @@ function fantasyMap() { // get square grid with some jirrering function getJitteredGrid() { let sizeMod = rn((graphWidth + graphHeight) / 1500, 2); // screen size modifier - spacing = rn(7.5 * sizeMod / graphSize, 2); // space between points before jirrering + spacing = rn(7.5 * sizeMod / graphSize / cellsSpread, 2); // space between points before jirrering const radius = spacing / 2; // square radius const jittering = radius * 0.9; // max deviation const jitter = function() {return Math.random() * 2 * jittering - jittering;}; @@ -10127,6 +10135,9 @@ function fantasyMap() { localStorage.setItem("mapWidth", mapWidthInput.value); localStorage.setItem("mapHeight", mapHeightInput.value); } + if (id === 'cellsSpreadInput') { + cellsSpread = cellsSpreadOutput.value = +this.value; + } if (id === "sizeInput") { graphSize = sizeOutput.value = +this.value; if (graphSize === 3) {sizeOutput.style.color = "red";}