Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 3x 3x 3x 2x 2x 3x 3x 3x 3x 3x 3x 3x 3x 3x | import type { Ref } from 'vue'; export function useMouseCanvasPosition(canvasRef: Ref<HTMLCanvasElement | null>) { const getMousePosition = (event: MouseEvent | TouchEvent | any) => { const canvas = canvasRef.value; if (!canvas) return { x: 0, y: 0 }; const rect = canvas.getBoundingClientRect(); const isTouchEvent = 'touches' in event; const clientX = isTouchEvent ? event.touches[0]?.clientX : event.clientX; const clientY = isTouchEvent ? event.touches[0]?.clientY : event.clientY; return { x: clientX - rect.left, y: clientY - rect.top, }; }; return { getMousePosition }; } |