Fixed canvas resizing bug

The canvas size was not being updated after opening a png
This commit is contained in:
unsettledgames 2020-09-22 11:34:36 +02:00
parent 93c73f939c
commit b595026ea8
5 changed files with 36 additions and 8 deletions

View File

@ -1102,6 +1102,26 @@ svg {
width:400px;
justify-content: center;
}
select {
height:30px;
background-color: $basehover;
color: $basehovericon;
border:none;
position:relative;
left:10px;
option {
background-color: $basehover;
color:$basehovericon;
padding:5px;
}
option:checked, option:hover {
background-color: $basehovericon;
color:$basehovericonhover;
}
}
}
#rs-keep-ratio {

View File

@ -184,8 +184,8 @@ class Layer {
setCanvasOffset (offsetLeft, offsetTop) {
//horizontal offset
var minXOffset = -this.canvasSize[0] * zoom + 300;
var maxXOffset = window.innerWidth - 148;
var minXOffset = -this.canvasSize[0] * zoom;
var maxXOffset = window.innerWidth - 300;
if (offsetLeft < minXOffset)
this.canvas.style.left = minXOffset +'px';

View File

@ -39,7 +39,12 @@ function newPixel (width, height, editorMode, fileContent = null) {
layers[1] = new Layer(width, height, layers[1].canvas, layers[1].menuEntry);
currentLayer = layers[1];
currentLayer.canvas.style.zIndex = 2;
currentLayer.canvas.style.zIndex = 2;
// Updating canvas size
for (let i=0; i<nLayers; i++) {
layers[i].canvasSize = [width, height];
}
}
// Adding the checkerboard behind it

View File

@ -1,14 +1,10 @@
let resizeCanvasContainer = document.getElementById("resize-canvas");
let rcPivot = "middle";
let currentPivotObject;
let resizeCanvasInitialized = false;
let borders = {left: 0, right: 0, top: 0, bottom: 0};
function openResizeCanvasWindow() {
if (!resizeCanvasInitialized) {
resizeCanvasInitialized = true;
initResizeCanvasInputs();
}
initResizeCanvasInputs();
showDialogue('resize-canvas');
}

View File

@ -291,6 +291,13 @@
<span>
Keep current ratio <input type = "checkbox" id = "rs-keep-ratio"/>
</span>
<span>
Resizing algorithm:
<select name = "resize-algorithm">
<option value = "nearest-neighbor">Nearest neighbour</option>
<option value = "bilinear-interpolation">Bilinear</option>
</select>
</span>
</br>
<button id = "resize-sprite-confirm">Resize sprite</button>
</div>