mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-21 19:41:23 +01:00
expanded cell density range, added spread customization option
This commit is contained in:
parent
f5c507a94b
commit
240c77ebf2
2 changed files with 23 additions and 2 deletions
12
index.html
12
index.html
|
|
@ -385,12 +385,22 @@
|
||||||
<td></td>
|
<td></td>
|
||||||
<td onmouseover="tip('Cells density controls underlying graph size and hightly affects performance')">Map cells density</td>
|
<td onmouseover="tip('Cells density controls underlying graph size and hightly affects performance')">Map cells density</td>
|
||||||
<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>
|
||||||
<td>
|
<td>
|
||||||
<output id="sizeOutput">1</output>
|
<output id="sizeOutput">1</output>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<i onmouseover="tip('Lock to restrict option randomization on new map generation')" data-locked=0 id="lockTemplateInput" class="icon-lock-open"></i>
|
<i onmouseover="tip('Lock to restrict option randomization on new map generation')" data-locked=0 id="lockTemplateInput" class="icon-lock-open"></i>
|
||||||
|
|
|
||||||
13
script.js
13
script.js
|
|
@ -92,6 +92,7 @@ function fantasyMap() {
|
||||||
let elSelected;
|
let elSelected;
|
||||||
let autoResize = true;
|
let autoResize = true;
|
||||||
let graphSize;
|
let graphSize;
|
||||||
|
let cellsSpread;
|
||||||
let cells = [];
|
let cells = [];
|
||||||
let land = [];
|
let land = [];
|
||||||
let riversData = [];
|
let riversData = [];
|
||||||
|
|
@ -338,6 +339,12 @@ function fantasyMap() {
|
||||||
} else {
|
} else {
|
||||||
graphSize = +sizeInput.value;
|
graphSize = +sizeInput.value;
|
||||||
}
|
}
|
||||||
|
if (localStorage.getItem("cellsSpread")) {
|
||||||
|
cellsSpread = localStorage.getItem("cellsSpread");
|
||||||
|
cellsSpreadInput.value = cellsSpreadOutput.value = cellsSpread;
|
||||||
|
} else {
|
||||||
|
cellsSpread = +cellsSpreadInput.value;
|
||||||
|
}
|
||||||
if (localStorage.getItem("template")) {
|
if (localStorage.getItem("template")) {
|
||||||
templateInput.value = localStorage.getItem("template");
|
templateInput.value = localStorage.getItem("template");
|
||||||
lockTemplateInput.setAttribute("data-locked", 1);
|
lockTemplateInput.setAttribute("data-locked", 1);
|
||||||
|
|
@ -394,6 +401,7 @@ function fantasyMap() {
|
||||||
mapHeightInput.value = window.innerHeight;
|
mapHeightInput.value = window.innerHeight;
|
||||||
changeMapSize();
|
changeMapSize();
|
||||||
graphSize = sizeInput.value = sizeOutput.value = 1;
|
graphSize = sizeInput.value = sizeOutput.value = 1;
|
||||||
|
cellsSpread = cellsSpreadInput.value = cellsSpreadOutput.value = 1;
|
||||||
$("#options i[class^='icon-lock']").each(function() {
|
$("#options i[class^='icon-lock']").each(function() {
|
||||||
this.setAttribute("data-locked", 0);
|
this.setAttribute("data-locked", 0);
|
||||||
this.className = "icon-lock-open";
|
this.className = "icon-lock-open";
|
||||||
|
|
@ -7140,7 +7148,7 @@ function fantasyMap() {
|
||||||
// get square grid with some jirrering
|
// get square grid with some jirrering
|
||||||
function getJitteredGrid() {
|
function getJitteredGrid() {
|
||||||
let sizeMod = rn((graphWidth + graphHeight) / 1500, 2); // screen size modifier
|
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 radius = spacing / 2; // square radius
|
||||||
const jittering = radius * 0.9; // max deviation
|
const jittering = radius * 0.9; // max deviation
|
||||||
const jitter = function() {return Math.random() * 2 * jittering - jittering;};
|
const jitter = function() {return Math.random() * 2 * jittering - jittering;};
|
||||||
|
|
@ -10127,6 +10135,9 @@ function fantasyMap() {
|
||||||
localStorage.setItem("mapWidth", mapWidthInput.value);
|
localStorage.setItem("mapWidth", mapWidthInput.value);
|
||||||
localStorage.setItem("mapHeight", mapHeightInput.value);
|
localStorage.setItem("mapHeight", mapHeightInput.value);
|
||||||
}
|
}
|
||||||
|
if (id === 'cellsSpreadInput') {
|
||||||
|
cellsSpread = cellsSpreadOutput.value = +this.value;
|
||||||
|
}
|
||||||
if (id === "sizeInput") {
|
if (id === "sizeInput") {
|
||||||
graphSize = sizeOutput.value = +this.value;
|
graphSize = sizeOutput.value = +this.value;
|
||||||
if (graphSize === 3) {sizeOutput.style.color = "red";}
|
if (graphSize === 3) {sizeOutput.style.color = "red";}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue