This commit is contained in:
Azgaar 2020-04-26 21:12:54 +03:00
parent a2b93f1396
commit 8152ccbe9c
4 changed files with 12 additions and 10 deletions

View file

@ -1797,7 +1797,8 @@
<input data-tip="Maximal possible zoom level (should be > 1)" id="zoomExtentMax" class="paired" type="number" min=1 max=50 value=20> <input data-tip="Maximal possible zoom level (should be > 1)" id="zoomExtentMax" class="paired" type="number" min=1 max=50 value=20>
</td> </td>
<td> <td>
<i data-tip="Restore default [1, 20] zoom extent" id="zoomExtentDefault" class="icon-ccw"></i> <i data-tip="Restore default zoom extent (1, 20)" id="zoomExtentDefault" class="icon-ccw"></i>
<i data-tip="Allow to drag map beyond canvas borders" id="translateExtent" data-on=0 class="icon-hand-paper-o"></i>
</td> </td>
</tr> </tr>
@ -2186,7 +2187,7 @@
</div> </div>
<button id="coastlineEditStyle" data-tip="Edit coastline group style in Style Editor" class="icon-brush"></button> <button id="coastlineEditStyle" data-tip="Edit coastline group style in Style Editor" class="icon-brush"></button>
<button id="coastlineArea" data-tip="Lake area in selected units">0</button> <button id="coastlineArea" data-tip="Landmass area in selected units">0</button>
</div> </div>
<div id="reliefEditor" class="dialog" style="display: none"> <div id="reliefEditor" class="dialog" style="display: none">

View file

@ -952,8 +952,6 @@ function drawCoastline() {
const waterMask = defs.select("#water"); const waterMask = defs.select("#water");
lineGen.curve(d3.curveBasisClosed); lineGen.curve(d3.curveBasisClosed);
zoom.translateExtent([[-200, -200],[graphWidth+200, graphHeight+200]]);
for (const i of cells.i) { for (const i of cells.i) {
const startFromEdge = !i && cells.h[i] >= 20; const startFromEdge = !i && cells.h[i] >= 20;
if (!startFromEdge && cells.t[i] !== -1 && cells.t[i] !== 1) continue; // non-edge cell if (!startFromEdge && cells.t[i] !== -1 && cells.t[i] !== 1) continue; // non-edge cell

View file

@ -61,7 +61,7 @@ function editCoastline(node = d3.event.target) {
lineGen.curve(d3.curveBasisClosed); lineGen.curve(d3.curveBasisClosed);
const f = +elSelected.attr("data-f"); const f = +elSelected.attr("data-f");
const vertices = pack.features[f].vertices; const vertices = pack.features[f].vertices;
const points = vertices.map(v => pack.vertices.p[v]); const points = clipPoly(vertices.map(v => pack.vertices.p[v]), 1);
const d = round(lineGen(points)); const d = round(lineGen(points));
elSelected.attr("d", d); elSelected.attr("d", d);
defs.select("mask#land > path#land_"+f).attr("d", d); // update land mask defs.select("mask#land > path#land_"+f).attr("d", d); // update land mask

View file

@ -118,6 +118,7 @@ optionsContent.addEventListener("click", function(event) {
else if (id === "optionsMapHistory") showSeedHistoryDialog(); else if (id === "optionsMapHistory") showSeedHistoryDialog();
else if (id === "optionsCopySeed") copyMapURL(); else if (id === "optionsCopySeed") copyMapURL();
else if (id === "zoomExtentDefault") restoreDefaultZoomExtent(); else if (id === "zoomExtentDefault") restoreDefaultZoomExtent();
else if (id === "translateExtent") toggleTranslateExtent(event.target);
}); });
function mapSizeInputChange() { function mapSizeInputChange() {
@ -138,7 +139,6 @@ function changeMapSize() {
landmass.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight); landmass.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight);
oceanPattern.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight); oceanPattern.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight);
oceanLayers.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight); oceanLayers.select("rect").attr("x", 0).attr("y", 0).attr("width", maxWidth).attr("height", maxHeight);
//defs.select("#mapClip > rect").attr("width", maxWidth).attr("height", maxHeight);
fitScaleBar(); fitScaleBar();
if (window.fitLegendBox) fitLegendBox(); if (window.fitLegendBox) fitLegendBox();
@ -153,9 +153,6 @@ function applyMapSize() {
svgHeight = Math.min(graphHeight, window.innerHeight); svgHeight = Math.min(graphHeight, window.innerHeight);
svg.attr("width", svgWidth).attr("height", svgHeight); svg.attr("width", svgWidth).attr("height", svgHeight);
zoom.translateExtent([[0, 0], [graphWidth, graphHeight]]).scaleExtent([zoomMin, zoomMax]).scaleTo(svg, zoomMin); zoom.translateExtent([[0, 0], [graphWidth, graphHeight]]).scaleExtent([zoomMin, zoomMax]).scaleTo(svg, zoomMin);
//viewbox.attr("transform", null).attr("clip-path", "url(#mapClip)");
//defs.append("clipPath").attr("id", "mapClip").append("rect").attr("x", 0).attr("y", 0).attr("width", graphWidth).attr("height", graphHeight);
//zoom.translateExtent([[-svgWidth*.2, -graphHeight*.2], [svgWidth*1.2, graphHeight*1.2]]);
} }
function toggleFullscreen() { function toggleFullscreen() {
@ -171,6 +168,12 @@ function toggleFullscreen() {
changeMapSize(); changeMapSize();
} }
function toggleTranslateExtent(el) {
const on = el.dataset.on = +!(+el.dataset.on);
if (on) zoom.translateExtent([[-graphWidth/2, -graphHeight/2], [graphWidth*1.5, graphHeight*1.5]]);
else zoom.translateExtent([[0, 0], [graphWidth, graphHeight]]);
}
function generateMapWithSeed() { function generateMapWithSeed() {
if (optionsSeed.value == seed) { if (optionsSeed.value == seed) {
tip("The current map already has this seed", false, "error"); tip("The current map already has this seed", false, "error");