Fixed pasting selection with cusor out of canvas

This commit is contained in:
Nicola 2022-01-12 23:13:53 +01:00
parent eada0f7ab1
commit 37d21f5dec
3 changed files with 4 additions and 15 deletions

View File

@ -44,6 +44,10 @@ class MoveSelectionTool extends DrawingTool {
return;
if (this.lastCopiedSelection === undefined)
return;
if (!(this.currMousePos[0]/currFile.zoom >= 0 && this.currMousePos[1]/currFile.zoom >= 0 &&
this.currMousePos[0]/currFile.zoom < currFile.canvasSize[0] && this.currMousePos[1]/currFile.zoom < currFile.canvasSize[1]))
this.currMousePos = [currFile.canvasSize[0]*currFile.zoom / 2, currFile.canvasSize[1]*currFile.zoom /2];
// Finish the current selection and start a new one with the same data
if (!this.cutting) {
this.endSelection();

View File

@ -67,10 +67,6 @@ class RectangularSelectionTool extends SelectionTool {
this.moveTool.setSelectionData(this.getSelection(), this);
}
copySelection() {
super.copySelection();
}
cutSelection() {
super.cutSelection();
currFile.currentLayer.context.clearRect(this.currSelection.left-0.5, this.currSelection.top-0.5,

View File

@ -1,10 +1,3 @@
/** TODO
* - Once the selected pixels have been obtained, save the selection outline in an image data
* - The move tool will then move those image datas and they'll be pasted on the right layer
* at the end of the selection
*
*/
class SelectionTool extends Tool {
switchFunc = undefined;
moveTool = undefined;
@ -144,10 +137,6 @@ class SelectionTool extends Tool {
currFile.VFXLayer.canvas.style.zIndex = MIN_Z_INDEX;
}
copySelection() {
}
cursorInSelectedArea(mousePos) {
let floored = [Math.floor(mousePos[0] / currFile.zoom) - this.moveOffset[0],