https://github.com/codewell/get-canvas-mouse-position
Get the position of a mouse on a canvas triggered by an event
https://github.com/codewell/get-canvas-mouse-position
Last synced: 11 months ago
JSON representation
Get the position of a mouse on a canvas triggered by an event
- Host: GitHub
- URL: https://github.com/codewell/get-canvas-mouse-position
- Owner: codewell
- License: mit
- Created: 2019-11-12T18:18:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T02:16:39.000Z (over 3 years ago)
- Last Synced: 2025-02-22T07:31:51.498Z (over 1 year ago)
- Language: JavaScript
- Size: 792 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @codewell/get-canvas-mouse-position
Get the position of a mouse on a canvas triggered by an event.
## Installation
```
npm install @codewell/get-canvas-mouse-position
```
## Basic usage
```JavaScript
import getCanvasMousePosition from '@codewell/get-canvas-mouse-position':
const handleClick = (event) => {
const mousePosition = getCanvasMousePosition(event);
const {x, y} = mousePosition; // The coordinate that was clicked on the canvas
}
return (
)
```