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:
parent
7dec2f1490
commit
ab0b3e81e3
@ -2,6 +2,7 @@ function changeTool (selectedTool) {
|
|||||||
// Ending any selection in progress
|
// Ending any selection in progress
|
||||||
if (currentTool.includes("select") && !selectedTool.includes("select") && !selectionCanceled) {
|
if (currentTool.includes("select") && !selectedTool.includes("select") && !selectionCanceled) {
|
||||||
endSelection();
|
endSelection();
|
||||||
|
console.log("FINISCO");
|
||||||
}
|
}
|
||||||
//set tool and temp tje tje tpp;
|
//set tool and temp tje tje tpp;
|
||||||
currentTool = selectedTool;
|
currentTool = selectedTool;
|
||||||
|
@ -23,6 +23,12 @@ window.addEventListener("mousedown", function (mouseEvent) {
|
|||||||
currentTool = 'eyedropper';
|
currentTool = 'eyedropper';
|
||||||
else if (mouseEvent.target.className == 'drawingCanvas' && (currentTool == 'pencil' || currentTool == 'eraser'))
|
else if (mouseEvent.target.className == 'drawingCanvas' && (currentTool == 'pencil' || currentTool == 'eraser'))
|
||||||
new HistoryStateEditCanvas();
|
new HistoryStateEditCanvas();
|
||||||
|
else if (currentTool == 'moveselection') {
|
||||||
|
if (!cursorInSelectedArea()) {
|
||||||
|
changeTool('pencil');
|
||||||
|
undo();
|
||||||
|
}
|
||||||
|
}
|
||||||
//saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])});
|
//saveHistoryState({type: 'canvas', canvas: context.getImageData(0, 0, canvasSize[0], canvasSize[1])});
|
||||||
|
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
17
js/_move.js
17
js/_move.js
@ -1,4 +1,5 @@
|
|||||||
var imageDataToMove;
|
var imageDataToMove;
|
||||||
|
var originalDataPosition;
|
||||||
var canMoveSelection = false;
|
var canMoveSelection = false;
|
||||||
var lastMovePos;
|
var lastMovePos;
|
||||||
var selectionCanceled = false;
|
var selectionCanceled = false;
|
||||||
@ -19,13 +20,6 @@ function updateMovePreview(mouseEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function endSelection() {
|
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);
|
TMPLayer.context.clearRect(0, 0, TMPLayer.canvas.width, TMPLayer.canvas.height);
|
||||||
VFXLayer.context.clearRect(0, 0, VFXLayer.canvas.width, VFXLayer.canvas.height);
|
VFXLayer.context.clearRect(0, 0, VFXLayer.canvas.width, VFXLayer.canvas.height);
|
||||||
|
|
||||||
@ -52,10 +46,19 @@ function endSelection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastMovePos !== undefined) {
|
||||||
currentLayer.context.putImageData(
|
currentLayer.context.putImageData(
|
||||||
imageDataToMove,
|
imageDataToMove,
|
||||||
Math.round(lastMovePos[0] / zoom - imageDataToMove.width / 2),
|
Math.round(lastMovePos[0] / zoom - imageDataToMove.width / 2),
|
||||||
Math.round(lastMovePos[1] / zoom - imageDataToMove.height / 2));
|
Math.round(lastMovePos[1] / zoom - imageDataToMove.height / 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currentLayer.context.putImageData(
|
||||||
|
imageDataToMove,
|
||||||
|
originalDataPosition[0],
|
||||||
|
originalDataPosition[1]);
|
||||||
|
}
|
||||||
|
|
||||||
selectionCanceled = true;
|
selectionCanceled = true;
|
||||||
|
isRectSelecting = false;
|
||||||
}
|
}
|
@ -71,10 +71,10 @@ function endRectSelection(mouseEvent) {
|
|||||||
// Selecting the move tool
|
// Selecting the move tool
|
||||||
currentTool = 'moveselection';
|
currentTool = 'moveselection';
|
||||||
currentToolTemp = currentTool;
|
currentToolTemp = currentTool;
|
||||||
|
|
||||||
|
originalDataPosition = [startX, startY];
|
||||||
// Updating the cursor
|
// Updating the cursor
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
|
||||||
//currentLayer.context.putImageData(imageData, startX, startY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawRect(x, y) {
|
function drawRect(x, y) {
|
||||||
|
Loading…
Reference in New Issue
Block a user