ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

eventToPosition accounting for canvas scale #139

Closed Pidroh closed 5 years ago

Pidroh commented 6 years ago

Previously mouse position would come wrong if the canvas was scaled. The two lines added resolve this issue

ondras commented 6 years ago

Interesting... what kind of scaling are we talking about here? There already is a scaling compensation applied (previous two lines) that works for CSS-based width/height. I suppose this one tackles CSS transformations (the scale() function in particular)?

Pidroh commented 6 years ago

Yes, exactly. I've been having some trouble getting the size just right on mobile... My problems are more likely to be related to a lack of CSS experience, but I ended up using scaling to solve the problem. I thought it would be useful so I submitted it, but since after all of these years no one has brought the issue to light, maybe it's not so important.

ondras commented 5 years ago

@Pidroh perhaps you would be able to solve your mobile sizing using CSS width/height properties instead of applying transforms?

I will try to setup a testing scenario that accounts for all possible sizing approaches, so that I can figure out a simpler coordinate transformation that is not based on a particular CSS property.

ondras commented 5 years ago

I believed I fixed the issue by actually simplifying the original code :)

Thanks for the suggestion, bugreport and pull request!