Rescale style option for submaps.

This commit is contained in:
Mészáros Gergely 2022-04-16 22:41:42 +02:00
parent 53dc9a452d
commit e85f5e39d6

View file

@ -20,10 +20,11 @@ window.UISubmap = (function () {
$(this).dialog("close");
}
}
});
}
});
}
function openRemapOptions() {
function openRemapOptions() {
resetZoom(0);
$("#remapOptionsDialog").dialog({
title: "Resampler options",
@ -38,7 +39,6 @@ window.UISubmap = (function () {
Cancel: function () {
$(this).dialog("close");
}
}
});
}
@ -51,6 +51,18 @@ window.UISubmap = (function () {
console.error("Unknown cell number!");
return;
}
});
}
/* callbacks */
const resampleCurrentMap = debounce(function () {
// Resample the whole map to different cell resolution or shape
const cellNumId = Number(document.getElementById("submapPointsInput").value);
if (!cellsDensityConstants[cellNumId]) {
console.error("Unknown cell number!");
return;
}
changeCellsDensity(cellNumId);
WARN && console.warn("Resampling current map");
startResample({
@ -64,9 +76,9 @@ window.UISubmap = (function () {
projection: (x, y) => [x, y],
inverse: (x, y) => [x, y]
});
}, 1000);
}, 1000);
const generateSubmap = debounce(function () {
const generateSubmap = debounce(function () {
// Create submap from the current map
// submap limits defined by the current window size (canvas viewport)
@ -105,9 +117,9 @@ window.UISubmap = (function () {
populationRateInput.value = populationRateOutput.value = rn((populationRate = populationRateOutput.value / scale), 2);
customization = 0;
startResample(options);
}, 1000);
}, 1000);
async function startResample(options) {
async function startResample(options) {
// Do model changes with Submap.resample then do view changes if needed.
undraw();
resetZoom(0);
@ -140,13 +152,14 @@ window.UISubmap = (function () {
turnButtonOn("toggleMarkers");
if (ThreeD.options.isOn) ThreeD.redraw();
if ($("#worldConfigurator").is(":visible")) editWorld();
}
}
function changeStyles(scale) {
function changeStyles(scale) {
// resize burgIcons
const burgIcons = [...document.getElementById("burgIcons").querySelectorAll("g")];
for (const bi of burgIcons) {
const newRadius = rn(minmax(bi.getAttribute('size') * scale, 0.2, 10), 2);
const newRadius = rn(minmax(scale, 0.2, 10) * 0.8, 2);
styleRadiusInput.value = newRadius;
changeRadius(newRadius, bi.id);
const swAttr = bi.attributes['stroke-width'];
swAttr.value = +swAttr.value * scale;
@ -165,9 +178,9 @@ window.UISubmap = (function () {
emblemsProvinceSizeInput.value = minmax(+emblemsProvinceSizeInput.value * emblemMod, 0.5, 5);
emblemsBurgSizeInput.value = minmax(+emblemsBurgSizeInput.value * emblemMod, 0.5, 5);
drawEmblems();
}
}
function showSubmapErrorHandler(error) {
function showSubmapErrorHandler(error) {
ERROR && console.error(error);
clearMainTip();
@ -185,7 +198,4 @@ window.UISubmap = (function () {
},
position: {my: "center", at: "center", of: "svg"}
});
}
return {openSubmapOptions, openRemapOptions}
})();
}