-1

The tablet we have is this:

enter image description here

I have a small canvas in a web page (around 790x480) and when using the pen the area of the tablet that matches the canvas it's too small. This happens because the tablet area matches the full resolution of the screen, while my small canvas is just part of the screen.

enter image description here

How can I "caputure" the pen inside the canvas while leaving the mouse "free"?

devamat
  • 2,293
  • 6
  • 27
  • 50
  • I never played with it myself, but if I had to, I would look into the [PointerEvent API](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent). It seems you can detect if the event was of type "pen", and in this case you could apply a transformation on your coords. Now beware that some pen events might also be caused by tablets with screens, where it will be odd to not draw at the correct position. – Kaiido Mar 06 '18 at 13:36
  • Thanks, I'll check it out! – devamat Mar 07 '18 at 02:22

1 Answers1

0

I found out that the software that comes with the tablet allows you to map the area where the pen should draw, so simply set that to match the area of the canvas and you're done.

devamat
  • 2,293
  • 6
  • 27
  • 50