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