I'm making a HUD mod for a game and the sprite drawing function it gives doesn't scale anything according to aspect ratio so I have to calculate it manually, this would be simple enough if it at least handled rotation properly, but by rotating it 90 degrees, the scale seemingly inverts, being twice as wide and half as tall.
Normal scale:
Rotated ~45 degrees:
Rotated 90 degrees:
I've tried to fix this for a while and this is the best I could come up with:
float startscalex = 0.5625;
float startscaley = 1;
float scalex = lerp(startscalex, startscaley, abs(sin(rot)));
float scaley = lerp(startscalex, startscaley, abs(cos(rot)));
This at least seems to have fixed 90 degree rotation:
But anything not divisible by 90 degrees is still skewed: