mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed more bugs 🆒 🆒
This commit is contained in:
19
js/_move.js
19
js/_move.js
@@ -1,4 +1,5 @@
|
||||
var imageDataToMove;
|
||||
var originalDataPosition;
|
||||
var canMoveSelection = false;
|
||||
var lastMovePos;
|
||||
var selectionCanceled = false;
|
||||
@@ -19,13 +20,6 @@ function updateMovePreview(mouseEvent) {
|
||||
}
|
||||
|
||||
function endSelection() {
|
||||
// We have to make something smarter:
|
||||
// Take the selected data
|
||||
// Take the data underlying the selected data
|
||||
// for every element in the selected data
|
||||
// if the current pixel is empty
|
||||
// copy the pixel in the selected data
|
||||
|
||||
TMPLayer.context.clearRect(0, 0, TMPLayer.canvas.width, TMPLayer.canvas.height);
|
||||
VFXLayer.context.clearRect(0, 0, VFXLayer.canvas.width, VFXLayer.canvas.height);
|
||||
|
||||
@@ -52,10 +46,19 @@ function endSelection() {
|
||||
}
|
||||
}
|
||||
|
||||
currentLayer.context.putImageData(
|
||||
if (lastMovePos !== undefined) {
|
||||
currentLayer.context.putImageData(
|
||||
imageDataToMove,
|
||||
Math.round(lastMovePos[0] / zoom - imageDataToMove.width / 2),
|
||||
Math.round(lastMovePos[1] / zoom - imageDataToMove.height / 2));
|
||||
}
|
||||
else {
|
||||
currentLayer.context.putImageData(
|
||||
imageDataToMove,
|
||||
originalDataPosition[0],
|
||||
originalDataPosition[1]);
|
||||
}
|
||||
|
||||
selectionCanceled = true;
|
||||
isRectSelecting = false;
|
||||
}
|
Reference in New Issue
Block a user