Files
ReplayModCinematic/src/main/java/eu/crushedpixel/replaymod/utils/BoundingUtils.java
CrushedPixel e22b37babe Created ReplayAsset interface and AssetRepository class which can contain such ReplayAssets. ReplayAssets allow users to add custom Files (so far only images, might be extended by .obj files) to the Replay which will later be used for CustomImageObjects.
Created GuiReplayManager to allow users to manage their assets.
Created BoundingUtils class to provide a simple method to fit an image into given bounds. This implementation fixes https://trello.com/c/WTnicWkJ/
2015-07-07 18:45:48 +02:00

26 lines
617 B
Java

package eu.crushedpixel.replaymod.utils;
import org.lwjgl.util.Dimension;
public class BoundingUtils {
public static Dimension fitIntoBounds(Dimension toFit, Dimension bounds) {
int width = toFit.getWidth();
int height = toFit.getHeight();
float w = (float)width/bounds.getWidth();
float h = (float)height/bounds.getHeight();
if(w > h) {
height = (int)(height/w);
width = (int)(width/w);
} else {
height = (int)(height/h);
width = (int)(width/h);
}
return new Dimension(width, height);
}
}