mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
round map coordinates
This commit is contained in:
parent
cfdb3a35df
commit
3be986828e
1 changed files with 6 additions and 6 deletions
12
main.js
12
main.js
|
|
@ -880,8 +880,8 @@ function openNearSeaLakes() {
|
|||
function defineMapSize() {
|
||||
const [size, latitude] = getSizeAndLatitude();
|
||||
const randomize = new URL(window.location.href).searchParams.get("options") === "default"; // ignore stored options
|
||||
if (randomize || !locked("mapSize")) mapSizeOutput.value = mapSizeInput.value = size;
|
||||
if (randomize || !locked("latitude")) latitudeOutput.value = latitudeInput.value = latitude;
|
||||
if (randomize || !locked("mapSize")) mapSizeOutput.value = mapSizeInput.value = rn(size);
|
||||
if (randomize || !locked("latitude")) latitudeOutput.value = latitudeInput.value = rn(latitude);
|
||||
|
||||
function getSizeAndLatitude() {
|
||||
const template = document.getElementById("templateInput").value; // heightmap template
|
||||
|
|
@ -914,11 +914,11 @@ function calculateMapCoordinates() {
|
|||
const size = +document.getElementById("mapSizeOutput").value;
|
||||
const latShift = +document.getElementById("latitudeOutput").value;
|
||||
|
||||
const latT = (size / 100) * 180;
|
||||
const latN = 90 - ((180 - latT) * latShift) / 100;
|
||||
const latS = latN - latT;
|
||||
const latT = rn((size / 100) * 180, 1);
|
||||
const latN = rn(90 - ((180 - latT) * latShift) / 100, 1);
|
||||
const latS = rn(latN - latT, 1);
|
||||
|
||||
const lon = Math.min(((graphWidth / graphHeight) * latT) / 2, 180);
|
||||
const lon = rn(Math.min(((graphWidth / graphHeight) * latT) / 2, 180));
|
||||
mapCoordinates = {latT, latN, latS, lonT: lon * 2, lonW: -lon, lonE: lon};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue