I am using the canvas-sketch framework, and it does not have a built-in function to retrieve the mouse position inside the canvas. How could I set the value of the mouse to the x and y of the mouse position inside the canvas?
const canvasSketch = require('canvas-sketch');
const Victor = require('victor');
const settings = {
dimensions: [1080, 1080]
};
let pos;
let mouse;
const sketch = () => {
return ({
context,
width,
height
}) => {
context.fillStyle = 'white';
context.fillRect(0, 0, width, height);
pos = new Victor(width / 2, height / 2);
};
};
canvasSketch(sketch, settings);