mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed lasso selection
This commit is contained in:
parent
ac18dff161
commit
d92a2cd1cd
@ -8,9 +8,6 @@ class LassoSelectionTool extends SelectionTool {
|
||||
|
||||
onStart(mousePos) {
|
||||
super.onStart(mousePos);
|
||||
|
||||
// Putting the vfx layer on top of everything
|
||||
currFile.VFXLayer.canvas.style.zIndex = MAX_Z_INDEX;
|
||||
// clearSelection();
|
||||
|
||||
this.currentPixels = [];
|
||||
@ -32,11 +29,14 @@ class LassoSelectionTool extends SelectionTool {
|
||||
new HistoryState().EditCanvas();
|
||||
|
||||
this.currentPixels.push([this.startMousePos[0] / currFile.zoom, this.startMousePos[1] / currFile.zoom]);
|
||||
this.getSelection();
|
||||
|
||||
// Switch to the move tool so that the user can move the selection
|
||||
// Include extreme borders
|
||||
this.boundingBox.maxX++;
|
||||
this.boundingBox.maxY++;
|
||||
|
||||
// Switch to the move tool so that the user can move the selection
|
||||
this.switchFunc(this.moveTool);
|
||||
this.moveTool.setSelectionData(null, this);
|
||||
this.moveTool.setSelectionData(this.getSelection(), this);
|
||||
}
|
||||
|
||||
onSelect() {
|
||||
@ -54,10 +54,7 @@ class LassoSelectionTool extends SelectionTool {
|
||||
let prevPoint = [];
|
||||
|
||||
currFile.VFXLayer.context.clearRect(0, 0, currFile.canvasSize[0], currFile.canvasSize[1]);
|
||||
currFile.VFXLayer.context.strokeStyle = 'rgba(0,0,0,1)';
|
||||
currFile.VFXLayer.context.fillStyle = 'rgba(0,0,0,1)';
|
||||
currFile.VFXLayer.context.lineWidth = 1;
|
||||
currFile.VFXLayer.context.beginPath();
|
||||
|
||||
for (var index = 0; index < this.currentPixels.length; index ++) {
|
||||
point = this.currentPixels[index];
|
||||
|
@ -1,8 +1,5 @@
|
||||
/** TODO:
|
||||
* - Clear cut selection
|
||||
* - Clear copy selection
|
||||
* - Clear paste selection
|
||||
*
|
||||
* - Test with lasso
|
||||
*/
|
||||
|
||||
class MoveSelectionTool extends DrawingTool {
|
||||
@ -70,7 +67,6 @@ class MoveSelectionTool extends DrawingTool {
|
||||
onDrag(mousePos) {
|
||||
super.onDrag(mousePos);
|
||||
|
||||
// TODO: add (or subtract?) vector (boundingBoxCenter - canvasCenter);
|
||||
this.selectionTool.moveOffset =
|
||||
[Math.floor(mousePos[0] / currFile.zoom - currFile.canvasSize[0] / 2 - (this.selectionTool.boundingBoxCenter[0] - currFile.canvasSize[0]/2)),
|
||||
Math.floor(mousePos[1] / currFile.zoom - currFile.canvasSize[1] / 2- (this.selectionTool.boundingBoxCenter[1] - currFile.canvasSize[1]/2))];
|
||||
|
Loading…
Reference in New Issue
Block a user