mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
v1.0.13
This commit is contained in:
parent
723cf6a6c8
commit
d592403046
3 changed files with 40 additions and 5 deletions
1
libs/jquery-ui.css
vendored
1
libs/jquery-ui.css
vendored
|
|
@ -362,7 +362,6 @@ body .ui-dialog {
|
||||||
border: 0;
|
border: 0;
|
||||||
padding: .5em 1em;
|
padding: .5em 1em;
|
||||||
background: none;
|
background: none;
|
||||||
overflow: auto;
|
|
||||||
}
|
}
|
||||||
.ui-dialog .ui-dialog-buttonpane {
|
.ui-dialog .ui-dialog-buttonpane {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
|
||||||
|
|
@ -1117,7 +1117,8 @@ function getHeight(h) {
|
||||||
preview.width = grid.cellsX;
|
preview.width = grid.cellsX;
|
||||||
preview.height = grid.cellsY;
|
preview.height = grid.cellsY;
|
||||||
document.body.insertBefore(preview, optionsContainer);
|
document.body.insertBefore(preview, optionsContainer);
|
||||||
preview.addEventListener("mouseover", () => tip("Heightmap preview. Right click and 'Save image as..' to download the image"));
|
preview.addEventListener("mouseover", () => tip("Heightmap preview. Click to download the image"));
|
||||||
|
preview.addEventListener("click", downloadPreview);
|
||||||
drawHeightmapPreview();
|
drawHeightmapPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1137,6 +1138,41 @@ function getHeight(h) {
|
||||||
ctx.putImageData(imageData, 0, 0);
|
ctx.putImageData(imageData, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function downloadPreview() {
|
||||||
|
const preview = document.getElementById("preview");
|
||||||
|
const dataURL = preview.toDataURL("image/png");
|
||||||
|
|
||||||
|
const img = new Image();
|
||||||
|
img.src = dataURL;
|
||||||
|
|
||||||
|
img.onload = function() {
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
canvas.width = svgWidth;
|
||||||
|
canvas.height = svgHeight;
|
||||||
|
document.body.insertBefore(canvas, optionsContainer);
|
||||||
|
ctx.drawImage(img, 0, 0, svgWidth, svgHeight);
|
||||||
|
|
||||||
|
// const imageData = ctx.getImageData(0, 0, svgWidth, svgHeight);
|
||||||
|
// for (let i=0; i < imageData.data.length; i+=4) {
|
||||||
|
// const v = Math.min(rn(imageData.data[i] * gauss(1, .05, .9, 1.1, 3)), 255);
|
||||||
|
// imageData.data[i] = v;
|
||||||
|
// imageData.data[i+1] = v;
|
||||||
|
// imageData.data[i+2] = v;
|
||||||
|
// }
|
||||||
|
// ctx.putImageData(imageData, 0, 0);
|
||||||
|
|
||||||
|
const imgBig = canvas.toDataURL("image/png");
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.target = "_blank";
|
||||||
|
link.download = "heightmap_" + Date.now() + ".png";
|
||||||
|
link.href = imgBig;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
canvas.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openPerspectivePanel() {
|
function openPerspectivePanel() {
|
||||||
if ($("#perspectivePanel").is(":visible")) return;
|
if ($("#perspectivePanel").is(":visible")) return;
|
||||||
$("#perspectivePanel").dialog({
|
$("#perspectivePanel").dialog({
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ function editLabel() {
|
||||||
viewbox.on("touchmove mousemove", showEditorTips);
|
viewbox.on("touchmove mousemove", showEditorTips);
|
||||||
|
|
||||||
$("#labelEditor").dialog({
|
$("#labelEditor").dialog({
|
||||||
title: "Edit Label", resizable: false,
|
title: "Edit Label", resizable: false, width: fitContent(),
|
||||||
position: {my: "center top+10", at: "bottom", of: text, collision: "fit"},
|
position: {my: "center top+10", at: "bottom", of: text, collision: "fit"},
|
||||||
close: closeLabelEditor
|
close: closeLabelEditor
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue