From 8df8b3ac54b3782c09165579a05113d24bb5bda2 Mon Sep 17 00:00:00 2001 From: Nicola <47360416+unsettledgames@users.noreply.github.com> Date: Tue, 28 Dec 2021 22:51:18 +0100 Subject: [PATCH] Started lasso selection preview --- css/_splash-page.scss | 4 +-- js/ToolManager.js | 5 ++- js/layers/Layer.js | 8 +++-- js/layers/PixelGrid.js | 2 -- js/tools/LassoSelectionTool.js | 57 +++++++++++++++++++++++++++++++--- views/tools-menu.hbs | 2 +- 6 files changed, 62 insertions(+), 16 deletions(-) diff --git a/css/_splash-page.scss b/css/_splash-page.scss index fd03cdc..1bf440a 100644 --- a/css/_splash-page.scss +++ b/css/_splash-page.scss @@ -155,9 +155,9 @@ .sp-template { display: flex; align-items: center; - + text-transform: uppercase; - width:16%; + width:5.5em; border-radius:5%; margin-right:4%; margin-top:4%; diff --git a/js/ToolManager.js b/js/ToolManager.js index 65bcd5e..1b07d2d 100644 --- a/js/ToolManager.js +++ b/js/ToolManager.js @@ -38,7 +38,6 @@ const ToolManager = (() => { } function onMouseWheel(mouseEvent) { - console.log("MOUSE WHEEL"); if (!EditorState.documentCreated || Dialogue.isOpen()) return; @@ -125,11 +124,11 @@ const ToolManager = (() => { tools["eyedropper"].onEnd(mousePos, mouseEvent.target); } else if (!currFile.currentLayer.isLocked || !((Object.getPrototypeOf(currTool) instanceof DrawingTool))) { - currTool.onEnd(mousePos); + currTool.onEnd(mousePos, mouseEvent.target); } break; case 2: - tools["pan"].onEnd(mousePos); + tools["pan"].onEnd(mousePos, mouseEvent.target); break; case 3: currTool.onRightEnd(mousePos, mouseEvent.target); diff --git a/js/layers/Layer.js b/js/layers/Layer.js index 466086c..3922f5c 100644 --- a/js/layers/Layer.js +++ b/js/layers/Layer.js @@ -293,12 +293,14 @@ class Layer { while (true) { //set pixel // If the current tool is the brush - if (ToolManager.currentTool().name == 'brush' || ToolManager.currentTool().name == 'rectangle' || ToolManager.currentTool().name == 'ellipse') { + // REFACTOR: this is terrible + if (ToolManager.currentTool().name == 'brush' || ToolManager.currentTool().name == 'rectangle' || ToolManager.currentTool().name == 'ellipse' + || ToolManager.currentTool().name == 'lassoselect') { // I fill the rect - currFile.currentLayer.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); + this.context.fillRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); } else if (ToolManager.currentTool().name == 'eraser') { // In case I'm using the eraser I must clear the rect - currFile.currentLayer.context.clearRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); + this.context.clearRect(x0-Math.floor(brushSize/2), y0-Math.floor(brushSize/2), brushSize, brushSize); } //if we've reached the end goal, exit the loop diff --git a/js/layers/PixelGrid.js b/js/layers/PixelGrid.js index 5401ccb..8b9c5fb 100644 --- a/js/layers/PixelGrid.js +++ b/js/layers/PixelGrid.js @@ -82,8 +82,6 @@ class PixelGrid extends Layer { this.context.strokeStyle = Settings.getCurrSettings().pixelGridColour; - console.log("Line ditance: " + this.lineDistance) - // OPTIMIZABLE, could probably be a bit more elegant // Draw horizontal lines for (let i=0; i
  • -
  • +