import { useRecoilValue } from 'recoil' import { canvasState } from '@/store/canvasAtom' import { calculateIntersection, getInterSectionLineNotOverCoordinate } from '@/util/canvas-util' export function useMouse() { const canvas = useRecoilValue(canvasState) //가로선, 세로선의 교차점을 return const getIntersectMousePoint = (e) => { let pointer = canvas.getPointer(e.e) const mouseLines = canvas.getObjects().filter((obj) => obj.name === 'mouseLine') if (mouseLines.length < 2) { return { x: Math.round(pointer.x), y: Math.round(pointer.y) } } return getInterSectionLineNotOverCoordinate(mouseLines[0], mouseLines[1]) || { x: Math.round(pointer.x), y: Math.round(pointer.y) } } return { getIntersectMousePoint, } }