mouseline intersectionPoint수정
This commit is contained in:
parent
bbd0e365be
commit
543657bcd4
@ -454,7 +454,6 @@ export function useAuxiliaryDrawing(id) {
|
||||
const mouseDown = (e) => {
|
||||
canvas.renderAll()
|
||||
const pointer = getIntersectMousePoint(e)
|
||||
console.log(pointer)
|
||||
|
||||
mousePointerArr.current.push(pointer)
|
||||
if (mousePointerArr.current.length === 2) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { canvasState } from '@/store/canvasAtom'
|
||||
import { calculateIntersection } from '@/util/canvas-util'
|
||||
import { calculateIntersection, getInterSectionLineNotOverCoordinate } from '@/util/canvas-util'
|
||||
|
||||
export function useMouse() {
|
||||
const canvas = useRecoilValue(canvasState)
|
||||
@ -14,7 +14,7 @@ export function useMouse() {
|
||||
return pointer
|
||||
}
|
||||
|
||||
return calculateIntersection(mouseLines[0], mouseLines[1]) || pointer
|
||||
return getInterSectionLineNotOverCoordinate(mouseLines[0], mouseLines[1]) || pointer
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -333,7 +333,6 @@ export const findIntersection1 = (line1, line2) => {
|
||||
|
||||
export const calculateIntersection = (line1, line2) => {
|
||||
const result = intersect([line1.x1, line1.y1], [line1.x2, line1.y2], [line2.x1, line2.y1], [line2.x2, line2.y2])
|
||||
|
||||
if (!result) {
|
||||
return null
|
||||
}
|
||||
@ -366,6 +365,14 @@ export const calculateIntersection = (line1, line2) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const getInterSectionLineNotOverCoordinate = (line1, line2) => {
|
||||
const result = intersect([line1.x1, line1.y1], [line1.x2, line1.y2], [line2.x1, line2.y1], [line2.x2, line2.y2])
|
||||
if (result) {
|
||||
return { x: Math.round(result[0]), y: Math.round(result[1]) }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function findOrthogonalPoint(line1, line2) {
|
||||
// Calculate the intersection point of two lines
|
||||
const intersectionX =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user