This commit is contained in:
kamilzielinski93 2018-10-07 12:16:50 +00:00 committed by GitHub
commit d53401b89c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View file

@ -385,12 +385,22 @@
<td></td>
<td onmouseover="tip('Cells density controls underlying graph size and hightly affects performance')">Map cells density</td>
<td>
<input id="sizeInput" type="range" min="1" max="3" value="1">
<input id="sizeInput" type="range" min="0.3" max="3" step="0.1" value="1">
</td>
<td>
<output id="sizeOutput">1</output>
</td>
</tr>
<tr>
<td></td>
<td onmouseover="tip('Cells spread distance')">Spread distance</td>
<td>
<input id="cellsSpreadInput" type="range" min="0.5" max="2" step="0.1" value="1">
</td>
<td>
<output id="cellsSpreadOutput">1</output>
</td>
</tr>
<tr>
<td>
<i onmouseover="tip('Lock to restrict option randomization on new map generation')" data-locked=0 id="lockTemplateInput" class="icon-lock-open"></i>

View file

@ -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";}