mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 23:03:06 +00:00
2D: Make cursor size update on canvas zoom
This commit is contained in:
1 parent
7b626d39aa
commit
1d088a1298
1 file changed
+30
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user