From 1d088a1298719f37259f3e6956b2ba80fcb2dab5 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Wed, 18 Mar 2026 15:38:18 -0700 Subject: [PATCH] 2D: Make cursor size update on canvas zoom --- .../app/src/pages/PageDraw/PaintSurface.tsx | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/frontend/apps/artcraft/app/src/pages/PageDraw/PaintSurface.tsx b/frontend/apps/artcraft/app/src/pages/PageDraw/PaintSurface.tsx index 12946fa99f..13e1255c47 100644 --- a/frontend/apps/artcraft/app/src/pages/PageDraw/PaintSurface.tsx +++ b/frontend/apps/artcraft/app/src/pages/PageDraw/PaintSurface.tsx @@ -814,6 +814,17 @@ export const PaintSurface = ({ stage.scale({ x: newScale, y: newScale }); stage.position(newPos); + + const cursorNode = cursorShapeRef.current; + const cursorLayer = cursorLayerRef.current; + if (cursorNode && cursorLayer && cursorPositionRef.current) { + cursorLayer.x(-newPos.x / newScale); + cursorLayer.y(-newPos.y / newScale); + cursorLayer.scaleX(1 / newScale); + cursorLayer.scaleY(1 / newScale); + cursorNode.position(cursorPositionRef.current); + cursorLayer.batchDraw(); + } } }; @@ -855,6 +866,17 @@ export const PaintSurface = ({ stage.scale({ x: newScale, y: newScale }); stage.position(newPos); + + const cursorNode = cursorShapeRef.current; + const cursorLayer = cursorLayerRef.current; + if (cursorNode && cursorLayer && cursorPositionRef.current) { + cursorLayer.x(-newPos.x / newScale); + cursorLayer.y(-newPos.y / newScale); + cursorLayer.scaleX(1 / newScale); + cursorLayer.scaleY(1 / newScale); + cursorNode.position(cursorPositionRef.current); + cursorLayer.batchDraw(); + } } setLastPinchDistance(currentDistance); @@ -918,6 +940,14 @@ export const PaintSurface = ({ const cursorNode = cursorShapeRef.current; const cursorLayer = cursorLayerRef.current; if (cursorNode && cursorLayer) { + const stX = stage.x(); + const stY = stage.y(); + const scX = stage.scaleX(); + const scY = stage.scaleY(); + cursorLayer.x(-stX / scX); + cursorLayer.y(-stY / scY); + cursorLayer.scaleX(1 / scX); + cursorLayer.scaleY(1 / scY); cursorNode.position(pointer); cursorLayer.batchDraw(); }