From 30d68d3aea992f358619146c50954a1335c1a258 Mon Sep 17 00:00:00 2001 From: funny bot Date: Wed, 3 Jun 2026 12:24:36 -0700 Subject: [PATCH 1/2] Fix brush tool and fill bucket bugs on browser zoom --- engine/src/tools/Brush.js | 6 +++--- engine/src/view/paper-ext/Paper.hole.js | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/engine/src/tools/Brush.js b/engine/src/tools/Brush.js index 1dc54932d..f479c74bf 100644 --- a/engine/src/tools/Brush.js +++ b/engine/src/tools/Brush.js @@ -379,9 +379,9 @@ Wick.Tools.Brush = class extends Wick.Tool { } // Update croquis element canvas size - if(this.croquis.getCanvasWidth() !== this.paper.view._element.width || - this.croquis.getCanvasHeight() !== this.paper.view._element.height) { - this.croquis.setCanvasSize(this.paper.view._element.width, this.paper.view._element.height); + if(this.croquis.getCanvasWidth() !== this.paper.view._viewSize.width || + this.croquis.getCanvasHeight() !== this.paper.view._viewSize.height) { + this.croquis.setCanvasSize(this.paper.view._viewSize.width, this.paper.view._viewSize.height); } // Fake brush opacity in croquis by changing the opacity of the croquis canvas diff --git a/engine/src/view/paper-ext/Paper.hole.js b/engine/src/view/paper-ext/Paper.hole.js index 39f3262ae..a0c9570d4 100644 --- a/engine/src/view/paper-ext/Paper.hole.js +++ b/engine/src/view/paper-ext/Paper.hole.js @@ -80,6 +80,8 @@ var rasterResolution = paper.view.resolution * RASTER_BASE_RESOLUTION / window.devicePixelRatio; var layerPathsRaster = layerGroup.rasterize(rasterResolution, {insert:false}); + // Fixes issues with browser zoom + var zoomFactor = RASTER_BASE_RESOLUTION * layerPathsRaster.bounds.width / layerPathsRaster.width; var rasterCanvas = layerPathsRaster.canvas; var rasterCtx = rasterCanvas.getContext('2d'); @@ -98,8 +100,8 @@ layerPathsImageData = rasterCtx.getImageData(0, 0, layerPathsRaster.width, layerPathsRaster.height); var rasterPosition = layerPathsRaster.bounds.topLeft; - var x = (floodFillX - rasterPosition.x) * RASTER_BASE_RESOLUTION; - var y = (floodFillY - rasterPosition.y) * RASTER_BASE_RESOLUTION; + var x = (floodFillX - rasterPosition.x) * RASTER_BASE_RESOLUTION / zoomFactor; + var y = (floodFillY - rasterPosition.y) * RASTER_BASE_RESOLUTION / zoomFactor; x = Math.round(x); y = Math.round(y); @@ -168,6 +170,8 @@ } expandHole(resultHolePath); + // Fixes issues with browser zoom + resultHolePath.scale(zoomFactor, layerPathsRaster.bounds.topLeft); callback(resultHolePath); } floodFillProcessedImage.src = floodFillCanvas.toDataURL(); From f241da89c0fe8bc83dbcdb65bb884accf82ed6e9 Mon Sep 17 00:00:00 2001 From: funny bot Date: Sun, 14 Jun 2026 19:07:39 -0700 Subject: [PATCH 2/2] Fix eraser offset bug --- engine/src/view/paper-ext/Path.potrace.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/src/view/paper-ext/Path.potrace.js b/engine/src/view/paper-ext/Path.potrace.js index b6993602c..6c73f169a 100644 --- a/engine/src/view/paper-ext/Path.potrace.js +++ b/engine/src/view/paper-ext/Path.potrace.js @@ -34,6 +34,8 @@ paper.Path.inject({ var finalRasterResolution = paper.view.resolution*args.resolution/window.devicePixelRatio; var raster = this.rasterize(finalRasterResolution); + // Fixes issues with browser zoom + var zoomFactor = args.resolution * raster.bounds.width / raster.width; raster.remove(); var rasterDataURL = raster.toDataURL(); @@ -51,6 +53,7 @@ paper.Path.inject({ potracePath.remove(); potracePath.closed = true; potracePath.children[0].closed = true; + potracePath.children[0].scale(zoomFactor); args.done(potracePath.children[0]); } img.src = rasterDataURL;