mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
fix: submap - generate in current canvas size
This commit is contained in:
parent
50ee5150c1
commit
ced7b88054
6 changed files with 17 additions and 11 deletions
|
|
@ -210,16 +210,16 @@ function fitMapToScreen() {
|
|||
svgHeight = Math.min(+mapHeightInput.value, window.innerHeight);
|
||||
svg.attr("width", svgWidth).attr("height", svgHeight);
|
||||
|
||||
const zoomExtent = [
|
||||
[0, 0],
|
||||
[graphWidth, graphHeight]
|
||||
];
|
||||
|
||||
const zoomMin = rn(Math.max(svgWidth / graphWidth, svgHeight / graphHeight), 3);
|
||||
zoomExtentMin.value = zoomMin;
|
||||
const zoomMax = +zoomExtentMax.value;
|
||||
|
||||
zoom.translateExtent(zoomExtent).scaleExtent([zoomMin, zoomMax]).scaleTo(svg, zoomMin);
|
||||
zoom
|
||||
.translateExtent([
|
||||
[0, 0],
|
||||
[graphWidth, graphHeight]
|
||||
])
|
||||
.scaleExtent([zoomMin, zoomMax]);
|
||||
|
||||
fitScaleBar(scaleBar, svgWidth, svgHeight);
|
||||
if (window.fitLegendBox) fitLegendBox();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ function openSubmapTool() {
|
|||
const projection = (x, y) => [(x - x0) * scale, (y - y0) * scale];
|
||||
const inverse = (x, y) => [x / scale + x0, y / scale + y0];
|
||||
|
||||
applyGraphSize();
|
||||
fitMapToScreen();
|
||||
resetZoom(0);
|
||||
undraw();
|
||||
Resample.process({projection, inverse, scale});
|
||||
|
|
|
|||
|
|
@ -132,9 +132,12 @@ async function openTransformTool() {
|
|||
|
||||
const [projection, inverse] = getProjection();
|
||||
|
||||
applyGraphSize();
|
||||
fitMapToScreen();
|
||||
resetZoom(0);
|
||||
undraw();
|
||||
Resample.process({projection, inverse, scale: 1});
|
||||
|
||||
drawLayers();
|
||||
|
||||
INFO && console.groupEnd("transformMap");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue