JoeStrout / minimicro-sysdisk

Contents of the /sys disk for the Mini Micro virtual computer
20 stars 11 forks source link

Feature idea: Sprite.localToWorld and .worldToLocal #11

Open JoeStrout opened 1 year ago

JoeStrout commented 1 year ago

Sprites already have the concept of "local" and "world" coordinates, embodied in their localBounds and worldBounds properties.

But sometimes (as in #10), it's handy to convert between these coordinate systems. It might be nice to have localToWorld and worldToLocal methods that do this, taking into account scaling, rotation, and position in the same way that worldBounds does.

This would make it easier to figure out the sprite image pixel under a screen point, though that still will require a bit of math since images are centered on local 0,0.