fix(tool): assistShape
This commit is contained in:
@@ -6,6 +6,8 @@ import React, {
|
||||
useImperativeHandle,
|
||||
useRef,
|
||||
} from "react"
|
||||
import { useBottomToolsStore } from "../useBottomToolsStore"
|
||||
import { usePaperStore } from "../usePaperStore"
|
||||
import { useTopToolsStore } from "../useTopToolsStore"
|
||||
|
||||
interface AssistShapeComponentProps {
|
||||
@@ -18,6 +20,10 @@ const AssistShapeComponent = (
|
||||
) => {
|
||||
const { size } = props
|
||||
const scale = useTopToolsStore((state) => state.scale)
|
||||
const activeImage = useBottomToolsStore((state) => state.activeImage)
|
||||
const rasterScale = usePaperStore(
|
||||
(state) => state.rasterScale[activeImage] ?? 1
|
||||
)
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||
const lastPointerRef = useRef<{ x: number; y: number } | null>(null)
|
||||
|
||||
@@ -27,7 +33,7 @@ const AssistShapeComponent = (
|
||||
const ctx = canvas?.getContext("2d")
|
||||
if (!canvas || !ctx) return
|
||||
|
||||
const radius = Math.max(1, size * scale)
|
||||
const radius = Math.max(1, size * scale * rasterScale)
|
||||
const side = radius * 2
|
||||
const left = centerX - radius
|
||||
const top = centerY - radius
|
||||
@@ -41,7 +47,7 @@ const AssistShapeComponent = (
|
||||
ctx.arc(centerX, centerY, radius, 0, Math.PI * 2)
|
||||
ctx.stroke()
|
||||
},
|
||||
[scale, size]
|
||||
[rasterScale, scale, size]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user