2

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:

Normal scale

Rotated ~45 degrees:

Rotated ~45 degrees

Rotated 90 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:

fixed 90 degree rotation

But anything not divisible by 90 degrees is still skewed:

non-90 degree rotation

ΦXocę 웃 Пepeúpa ツ
  • 43,054
  • 16
  • 58
  • 83
Zolika1351
  • 21
  • 1
  • 1
    Not sure, if I got your issue right... If there is a scaling applied to the original bitmap (to compensate non-uniform scaling for aspect-ratio), then you have to unscale, rotate, and scale again. FYI: [SO: Rotate an image in C++ without using OpenCV functions](https://stackoverflow.com/a/56985104/7478597) – Scheff's Cat Feb 23 '21 at 11:38
  • This looks very much like you've mistaken the order in which linear transformations should be applied. In your case you seem to need "scale, then rotate". What you appear to be doing is "rotate, then scale". – Ruslan Feb 23 '21 at 15:05

0 Answers0