Getting correct mouse position in a CSS scaled canvas

旧时模样 提交于 2019-12-03 20:08:13

I've made a little demo using plain javascript. I've got a blog post explaning the process.

Take a look at the example with special note to where the variables sx and sy are being used. They're your scaling ratio. You'll basically need to apply this to any offsets within the canvas (i.e. mouse position in the screen minus the canvas offset).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!