mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
fix font size settings
This commit is contained in:
parent
7d299ff395
commit
1f10a8e281
2 changed files with 17 additions and 9 deletions
6
main.js
6
main.js
|
|
@ -476,12 +476,12 @@ function invokeActiveZooming() {
|
|||
|
||||
// rescale lables on zoom
|
||||
if (labels.style("display") !== "none") {
|
||||
labels.selectAll("g").each(function (d) {
|
||||
labels.selectAll("g").each(function () {
|
||||
if (this.id === "burgLabels") return;
|
||||
const desired = +this.dataset.size;
|
||||
const relative = Math.max(rn((desired + desired / scale) / 2, 2), 1);
|
||||
this.getAttribute("font-size", relative);
|
||||
const hidden = hideLabels.checked && (relative * scale < 6 || relative * scale > 50);
|
||||
this.setAttribute("font-size", relative);
|
||||
const hidden = hideLabels.checked && (relative * scale < 6 || relative * scale > 60);
|
||||
if (hidden) this.classList.add("hidden");
|
||||
else this.classList.remove("hidden");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -578,13 +578,21 @@ styleFontMinus.addEventListener("click", function () {
|
|||
});
|
||||
|
||||
function changeFontSize(size) {
|
||||
const legend = styleElementSelect.value === "legend";
|
||||
const coords = styleElementSelect.value === "coordinates";
|
||||
|
||||
const desSize = legend ? size : coords ? rn(size / scale ** 0.8, 2) : rn(size + size / scale);
|
||||
getEl().attr("data-size", size).attr("font-size", desSize);
|
||||
styleFontSize.value = size;
|
||||
if (legend) redrawLegend();
|
||||
|
||||
const getSizeOnScale = element => {
|
||||
// some labels are rescaled on zoom
|
||||
if (element === "labels") return Math.max(rn((size + size / scale) / 2, 2), 1);
|
||||
if (element === "coordinates") return rn(size / scale ** 0.8, 2);
|
||||
|
||||
// other has the same size
|
||||
return size;
|
||||
};
|
||||
|
||||
const scaleSize = getSizeOnScale(styleElementSelect.value);
|
||||
getEl().attr("data-size", size).attr("font-size", scaleSize);
|
||||
|
||||
if (styleElementSelect.value === "legend") redrawLegend();
|
||||
}
|
||||
|
||||
styleRadiusInput.addEventListener("change", function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue