stretchedmode: retain aspect ratio when scaling

This commit is contained in:
Lotto
2018-11-02 16:18:31 +01:00
parent 8b4b4c3ba1
commit fdfdf77ddc

View File

@@ -104,7 +104,7 @@ public abstract class StretchedModeMixin implements RSClient
{
factor = Ints.constrainToRange(factor, 0, 100);
scalingFactor = (100 - factor) / 100D;
scalingFactor = 1 + (factor / 100D);
}
@Inject
@@ -125,11 +125,8 @@ public abstract class StretchedModeMixin implements RSClient
int parentWidth = canvasParent.getWidth();
int parentHeight = canvasParent.getHeight();
int widthOffset = parentWidth - Constants.GAME_FIXED_WIDTH;
int heightOffset = parentHeight - Constants.GAME_FIXED_HEIGHT;
int newWidth = Constants.GAME_FIXED_WIDTH + (int) (widthOffset * scalingFactor);
int newHeight = Constants.GAME_FIXED_HEIGHT + (int) (heightOffset * scalingFactor);
int newWidth = Math.max(Constants.GAME_FIXED_WIDTH, (int) (parentWidth / scalingFactor));
int newHeight = Math.max(Constants.GAME_FIXED_HEIGHT, (int) (parentHeight / scalingFactor));
cachedRealDimensions = new Dimension(newWidth, newHeight);
}