markers - round coords on zoom

This commit is contained in:
Azgaar 2021-09-18 15:01:33 +03:00
parent f5258f6ed0
commit c8b7e9ccee

17
main.js
View file

@ -2,7 +2,7 @@
// https://github.com/Azgaar/Fantasy-Map-Generator // https://github.com/Azgaar/Fantasy-Map-Generator
"use strict"; "use strict";
const version = "1.661"; // generator version const version = "1.662"; // generator version
document.title += " v" + version; document.title += " v" + version;
// Switches to disable/enable logging features // Switches to disable/enable logging features
@ -493,15 +493,12 @@ function invokeActiveZooming() {
// rescale map markers // rescale map markers
if (+markers.attr("rescale") && markers.style("display") !== "none") { if (+markers.attr("rescale") && markers.style("display") !== "none") {
markers.selectAll("use").each(function () { markers.selectAll("use").each(function () {
const x = +this.dataset.x, const {x, y, size} = this.dataset;
y = +this.dataset.y, const actualSize = Math.max(rn(size * 5 + 25 / scale, 2), 1);
desired = +this.dataset.size; const actualX = rn(Number(x) - actualSize / 2, 2);
const size = Math.max(desired * 5 + 25 / scale, 1); const actualY = rn(Number(y) - actualSize, 2);
d3.select(this)
.attr("x", x - size / 2) d3.select(this).attr("x", actualX).attr("y", actualY).attr("width", actualSize).attr("height", actualSize);
.attr("y", y - size)
.attr("width", size)
.attr("height", size);
}); });
} }