mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
* Poles to have Different Temperature (Ref: Axial Tilt suggestion) (#964) * Initial Idea * Changed Names: Currently still only on NorthTemperature reliant, compadible version * Restored Generation of Temperature * Temperature Function found * Version Bump * Scuffed Saving solution * Current Version(without the save changes) * Globe Temperature Display * Individual Regeneration of Temperatures * Fixed Loading and Saving New Maps save a Dummy 0 at settings[17] * Final Version Bump (currently no description for the Update) --------- Co-authored-by: Azgaar <maxganiev@yandex.com> * chore: formatting * refactor: temperature inputs * feat: rework temperature generation alg * style: respore winds button * refactor: update options on load, don't update temperature UI * refactor: no need to keep compatibility here * fix: load temp setting from .map file --------- Co-authored-by: Leo <leonard.krusch@gmx.de>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
"use strict";
|
|
// FMG utils related to units
|
|
|
|
// conver temperature from °C to other scales
|
|
const temperatureConversionMap = {
|
|
"°C": temp => rn(temp) + "°C",
|
|
"°F": temp => rn((temp * 9) / 5 + 32) + "°F",
|
|
K: temp => rn(temp + 273.15) + "K",
|
|
"°R": temp => rn(((temp + 273.15) * 9) / 5) + "°R",
|
|
"°De": temp => rn(((100 - temp) * 3) / 2) + "°De",
|
|
"°N": temp => rn((temp * 33) / 100) + "°N",
|
|
"°Ré": temp => rn((temp * 4) / 5) + "°Ré",
|
|
"°Rø": temp => rn((temp * 21) / 40 + 7.5) + "°Rø"
|
|
};
|
|
|
|
function convertTemperature(temp, scale = temperatureScale.value || "°C") {
|
|
return temperatureConversionMap[scale](temp);
|
|
}
|
|
|
|
// corvent number to short string with SI postfix
|
|
function si(n) {
|
|
if (n >= 1e9) return rn(n / 1e9, 1) + "B";
|
|
if (n >= 1e8) return rn(n / 1e6) + "M";
|
|
if (n >= 1e6) return rn(n / 1e6, 1) + "M";
|
|
if (n >= 1e4) return rn(n / 1e3) + "K";
|
|
if (n >= 1e3) return rn(n / 1e3, 1) + "K";
|
|
return rn(n);
|
|
}
|
|
|
|
// getInteger number from user input data
|
|
function getInteger(value) {
|
|
const metric = value.slice(-1);
|
|
if (metric === "K") return parseInt(value.slice(0, -1) * 1e3);
|
|
if (metric === "M") return parseInt(value.slice(0, -1) * 1e6);
|
|
if (metric === "B") return parseInt(value.slice(0, -1) * 1e9);
|
|
return parseInt(value);
|
|
}
|