From f37a85cf55d12cb198f32712ee11526b67a76025 Mon Sep 17 00:00:00 2001 From: unsettledgames <47360416+unsettledgames@users.noreply.github.com> Date: Wed, 30 Jun 2021 22:13:59 +0200 Subject: [PATCH] Fixed #18 (fix by @liamortiz ) --- css/pixel-editor.scss | 2 +- js/_tools.js | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/css/pixel-editor.scss b/css/pixel-editor.scss index cf19900..4824761 100644 --- a/css/pixel-editor.scss +++ b/css/pixel-editor.scss @@ -1611,6 +1611,7 @@ div#pb-options { } #sp-quickstart-container { + height:100%; max-height: 500px; width:70%; float:right; @@ -1675,7 +1676,6 @@ div#pb-options { align-items: center; text-transform: uppercase; width:16%; - min-width: 100px; border-radius:5%; margin-right:4%; margin-top:4%; diff --git a/js/_tools.js b/js/_tools.js index a4afc6d..a6d374d 100644 --- a/js/_tools.js +++ b/js/_tools.js @@ -95,20 +95,14 @@ class Tool { } moveBrushPreview(cursorLocation) { - let toSub = 0; - // Prevents the brush to be put in the middle of pixels - if (this.currentBrushSize % 2 == 0) { - toSub = 0.5; - } - - brushPreview.style.left = (Math.ceil(cursorLocation[0] / zoom) * zoom // Stick to pixel grid - + currentLayer.canvas.offsetLeft // Account for canvas offset - - this.currentBrushSize * zoom / 2 // Center the brush preview - - zoom / 2 - toSub * zoom) + 'px'; // ??? - brushPreview.style.top = (Math.ceil(cursorLocation[1] / zoom) * zoom + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 - zoom / 2 - toSub * zoom) + 'px'; - - console.log("Brush coords: " + brushPreview.style.left + "," + brushPreview.style.top); - } + let toSub = 1; + // Prevents the brush to be put in the middle of pixels + if (this.currentBrushSize % 2 == 0) { + toSub = 0.5; + } + brushPreview.style.left = (Math.floor(cursorLocation[0] / zoom) * zoom + currentLayer.canvas.offsetLeft - this.currentBrushSize * zoom / 2 - zoom / 2 + toSub * zoom) + 'px'; + brushPreview.style.top = (Math.floor(cursorLocation[1] / zoom) * zoom + currentLayer.canvas.offsetTop - this.currentBrushSize * zoom / 2 - zoom / 2 + toSub * zoom) + 'px'; + } }