Merge branch 'poles-temperature' of https://github.com/Azgaar/Fantasy-Map-Generator into poles-temperature

This commit is contained in:
Azgaar 2023-08-06 13:10:43 +04:00
commit 0a55a3aab4
9 changed files with 62 additions and 34 deletions

View file

@ -636,4 +636,10 @@ export function resolveVersionConflicts(version) {
if (coa?.shield === "state") delete coa.shield;
});
}
if (version < 1.89) {
//May need a major bump
options.tempNorthPole = +temperatureNorthPoleInput.value;
options.tempSouthPole = +temperatureNorthPoleInput.value;
}
}

View file

@ -109,7 +109,7 @@ function getSettings() {
mapSize: mapSizeOutput.value,
latitudeO: latitudeOutput.value,
temperatureEquator: temperatureEquatorOutput.value,
temperaturePole: temperaturePoleOutput.value,
temperaturePole: 0, //Moved to options
prec: precOutput.value,
options: options,
mapName: mapName.value,

View file

@ -219,7 +219,7 @@ async function parseLoadedData(data) {
if (settings[14]) mapSizeInput.value = mapSizeOutput.value = minmax(settings[14], 1, 100);
if (settings[15]) latitudeInput.value = latitudeOutput.value = minmax(settings[15], 0, 100);
if (settings[16]) temperatureEquatorInput.value = temperatureEquatorOutput.value = settings[16];
if (settings[17]) temperaturePoleInput.value = temperaturePoleOutput.value = settings[17];
if (settings[17]) temperatureNorthPoleInput.value = temperatureNorthPoleOutput.value = settings[17]; //Not used see options: only for compatibility
if (settings[18]) precInput.value = precOutput.value = settings[18];
if (settings[19]) options = JSON.parse(settings[19]);
if (settings[20]) mapName.value = settings[20];
@ -589,6 +589,8 @@ async function parseLoadedData(data) {
// set options
yearInput.value = options.year;
eraInput.value = options.era;
temperatureNorthPoleOutput.value = temperatureNorthPoleInput.value = options.tempNorthPole;
temperatureSouthPoleOutput.value = temperatureSouthPoleInput.value = options.tempSouthPole;
shapeRendering.value = viewbox.attr("shape-rendering") || "geometricPrecision";
if (window.restoreDefaultEvents) restoreDefaultEvents();

View file

@ -25,7 +25,7 @@ function getMapData() {
mapSizeOutput.value,
latitudeOutput.value,
temperatureEquatorOutput.value,
temperaturePoleOutput.value,
0, //Dummy for tempNorthOutput.value
precOutput.value,
JSON.stringify(options),
mapName.value,

View file

@ -612,8 +612,10 @@ function randomizeOptions() {
tMin = -30; // temperature extremes
if (randomize || !locked("temperatureEquator"))
temperatureEquatorOutput.value = temperatureEquatorInput.value = rand(tMax - 10, tMax);
if (randomize || !locked("temperaturePole"))
temperaturePoleOutput.value = temperaturePoleInput.value = rand(tMin, tMin + 30);
if (randomize || !locked("temperatureNorthPole"))
temperatureNorthPoleOutput.value = temperatureNorthPoleInput.value = rand(tMin, tMin + 30);
if (randomize || !locked("temperatureSouthPole"))
temperatureSouthPoleOutput.value = temperatureSouthPoleInput.value = rand(tMin, tMin + 30);
// 'Units Editor' settings
const US = navigator.language === "en-US";

View file

@ -107,12 +107,19 @@ function editWorld() {
function updateGlobeTemperature() {
const tEq = +document.getElementById("temperatureEquatorOutput").value;
document.getElementById("temperatureEquatorF").innerHTML = rn((tEq * 9) / 5 + 32);
const tPole = +document.getElementById("temperaturePoleOutput").value;
document.getElementById("temperaturePoleF").innerHTML = rn((tPole * 9) / 5 + 32);
globe.selectAll(".tempGradient90").attr("stop-color", clr(1 - (tPole - tMin) / (tMax - tMin)));
globe.selectAll(".tempGradient60").attr("stop-color", clr(1 - (tEq - ((tEq - tPole) * 2) / 3 - tMin) / (tMax - tMin)));
globe.selectAll(".tempGradient30").attr("stop-color", clr(1 - (tEq - ((tEq - tPole) * 1) / 3 - tMin) / (tMax - tMin)));
const tNorthPole = +document.getElementById("temperatureNorthPoleOutput").value;
document.getElementById("temperatureNorthPoleF").innerHTML = rn((tNorthPole * 9) / 5 + 32);
const tSouthPole = +document.getElementById("temperatureSouthPoleOutput").value;
document.getElementById("temperatureSouthPoleF").innerHTML = rn((tSouthPole * 9) / 5 + 32);
//North to Equator to South
globe.select(".tempNorthGradient90").attr("stop-color", clr(1 - (tNorthPole - tMin) / (tMax - tMin)));
globe.select(".tempNorthGradient60").attr("stop-color", clr(1 - (tEq - ((tEq - tNorthPole) * 2) / 3 - tMin) / (tMax - tMin)));
globe.select(".tempNorthGradient30").attr("stop-color", clr(1 - (tEq - ((tEq - tNorthPole) * 1) / 3 - tMin) / (tMax - tMin)));
globe.select(".tempGradient0").attr("stop-color", clr(1 - (tEq - tMin) / (tMax - tMin)));
globe.select(".tempSouthGradient30").attr("stop-color", clr(1 - (tEq - ((tEq - tSouthPole) * 1) / 3 - tMin) / (tMax - tMin)));
globe.select(".tempSouthGradient60").attr("stop-color", clr(1 - (tEq - ((tEq - tSouthPole) * 2) / 3 - tMin) / (tMax - tMin)));
globe.select(".tempSouthGradient90").attr("stop-color", clr(1 - (tSouthPole - tMin) / (tMax - tMin)));
}
function updateWindDirections() {