mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
v. 0.60.05b
This commit is contained in:
parent
1b818bc855
commit
437026a42d
3 changed files with 49 additions and 9 deletions
|
|
@ -523,7 +523,7 @@ p {
|
|||
}
|
||||
|
||||
#cellInfo>div:nth-child(2) {
|
||||
width: 35%;
|
||||
width: 45%;
|
||||
}
|
||||
|
||||
#customizeOptions {
|
||||
|
|
|
|||
25
index.html
25
index.html
|
|
@ -31,8 +31,8 @@
|
|||
<script src="libs/polylabel.min.js"></script>
|
||||
<script src="libs/quantize.min.js" defer></script>
|
||||
<script src="libs/jquery.ui.touch-punch.min.js" defer></script>
|
||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.60.00b"/>
|
||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.60.00b"/>
|
||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.60.05b"/>
|
||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.60.05b"/>
|
||||
<link rel="stylesheet" type="text/css" href="libs/jquery-ui.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -1201,6 +1201,25 @@
|
|||
<div onmouseover="tip('Type area unit name, leave `square` just to add ² to the distance unit selected above')">Area unit: </div>
|
||||
<input id="areaUnit" onmouseover="tip('Type area unit name, leave `square` just to add ² to the distance unit selected above')" type="text" value="square">
|
||||
</div>
|
||||
|
||||
<div class="scaleHeader">
|
||||
<span class="icon-signal"></span>
|
||||
<div>Altitude: </div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Height unit: </div>
|
||||
<select onmouseover="tip('Select Height unit')" id="heightUnit">
|
||||
<option value="ft" selected>Feet</option>
|
||||
<option value="m">Meters</option>
|
||||
<option value="f">Fathoms</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<div onmouseover="tip('Select height exponent, i.e. a value showing altitude change sharpness')">Exponent: </div>
|
||||
<input id="heightExponent" onmouseover="tip('Select height exponent, i.e. a value showing altitude change sharpness')" onchange="heightOutput.value = this.value" type="range" min="1.5" max="2" value="1.73" step="0.01">
|
||||
<input id="heightOutput" onmouseover="tip('Select height exponent, i.e. a value showing altitude change sharpness')" type="text" class="output" value="1.73">
|
||||
</div>
|
||||
|
||||
<div class="scaleHeader">
|
||||
<span class="icon-minus"></span>
|
||||
<div>Scale bar: </div>
|
||||
|
|
@ -1269,5 +1288,5 @@
|
|||
<input type="file" accept=".txt" id="namesbaseToLoad">
|
||||
</div>
|
||||
|
||||
<script src="script.js?version=0.60.03b"></script>
|
||||
<script src="script.js?version=0.60.05b"></script>
|
||||
</body>
|
||||
|
|
|
|||
31
script.js
31
script.js
|
|
@ -485,8 +485,8 @@ function fantasyMap() {
|
|||
infoY.innerHTML = rn(point[1]);
|
||||
infoCell.innerHTML = i;
|
||||
infoArea.innerHTML = ifDefined(p.area, "n/a", 2);
|
||||
if (customization === 1) {infoHeight.innerHTML = heights[i];}
|
||||
else {infoHeight.innerHTML = ifDefined(p.height, "n/a");}
|
||||
if (customization === 1) {infoHeight.innerHTML = getFriendlyHeight(heights[i]);}
|
||||
else {infoHeight.innerHTML = getFriendlyHeight(p.height);}
|
||||
infoFlux.innerHTML = ifDefined(p.flux, "n/a", 2);
|
||||
let country = p.region === undefined ? "n/a" : p.region === "neutral" ? "neutral" : states[p.region].name + " (" + p.region + ")";
|
||||
infoCountry.innerHTML = country;
|
||||
|
|
@ -596,6 +596,19 @@ function fantasyMap() {
|
|||
return v;
|
||||
}
|
||||
|
||||
// get user-friendly (real-world) height value from map data
|
||||
function getFriendlyHeight(h) {
|
||||
let exponent = +heightExponent.value;
|
||||
let unit = heightUnit.value;
|
||||
let unitRatio = 1; // default calculations are in meters
|
||||
if (unit === "ft") unitRatio = 3.28; // if foot
|
||||
if (unit === "f") unitRatio = 0.5468; // if fathom
|
||||
let height = -990;
|
||||
if (h >= 20) height = Math.pow(h - 18, exponent);
|
||||
if (h < 20 && h > 0) height = (h - 20) / h * 50;
|
||||
return h + " (" + rn(height * unitRatio) + " " + unit + ")";
|
||||
}
|
||||
|
||||
// move brush radius circle
|
||||
function moveCircle(x, y, r, c) {
|
||||
let circle = debug.selectAll(".circle");
|
||||
|
|
@ -6800,6 +6813,13 @@ function fantasyMap() {
|
|||
ruler = viewbox.select("#ruler");
|
||||
debug = viewbox.select("#debug");
|
||||
|
||||
if (!d3.select("#defs-markers").size()) {
|
||||
let symbol = '<g id="defs-markers"><symbol id="marker0" viewBox="0 0 30 30"><path d="M6,19 l9,10 L24,19" fill="#000000" stroke="none"></path><circle cx="15" cy="15" r="10" stroke-width="1" stroke="#000000" fill="#ffffff"></circle><text x="50%" y="50%" fill="#000000" stroke-width="0" stroke="#000000" font-size="22px" dominant-baseline="central">?</text></symbol></g>';
|
||||
let cont = document.getElementsByTagName("defs");
|
||||
cont[0].insertAdjacentHTML("afterbegin", symbol);
|
||||
markers = viewbox.append("g").attr("id", "markers");
|
||||
}
|
||||
|
||||
// version control: ensure required groups are created with correct data
|
||||
if (!labels.select("#burgLabels").size()) {
|
||||
labels.append("g").attr("id", "burgLabels");
|
||||
|
|
@ -6989,7 +7009,7 @@ function fantasyMap() {
|
|||
// get square grid with some jirrering
|
||||
function getJitteredGrid() {
|
||||
let sizeMod = rn((graphWidth + graphHeight) / 1500, 2); // screen size modifier
|
||||
let spacing = rn(7.5 * sizeMod / graphSize, 2); // space between points before jirrering
|
||||
spacing = rn(7.5 * sizeMod / graphSize, 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;}
|
||||
|
|
@ -7773,8 +7793,9 @@ function fantasyMap() {
|
|||
|
||||
// get square grid cell index based on coords
|
||||
function getCellIndex(x, y) {
|
||||
let cellsX = Math.floor(graphWidth / spacing);
|
||||
let index = Math.floor(y / spacing) * cellsX + Math.floor(x / spacing);
|
||||
const index = diagram.find(x, y).index;
|
||||
// let cellsX = Math.round(graphWidth / spacing);
|
||||
// let index = Math.ceil(y / spacing) * cellsX + Math.round(x / spacing);
|
||||
return index;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue