use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class LoopFrameSkipping method hasSync.
/**
* Check if screen has sync locked.
*
* @param screen The screen reference.
* @return <code>true</code> if sync enabled, <code>false</code> else.
*/
private static boolean hasSync(Screen screen) {
final Config config = screen.getConfig();
final Resolution output = config.getOutput();
return config.isWindowed() && output.getRate() > 0;
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class LoopFrameSkipping method getMaxFrameTimeNano.
/**
* Get the maximum frame time in nano seconds.
*
* @param screen The screen reference.
* @return The maximum frame time in nano seconds.
*/
private static double getMaxFrameTimeNano(Screen screen) {
final Config config = screen.getConfig();
final Resolution source = config.getSource();
final double expectedRate = getExpectedRate(source);
return Constant.ONE_SECOND_IN_MILLI / expectedRate * Constant.NANO_TO_MILLI;
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class DrawableTest method testMissingDpi.
/**
* Test success cases with missing DPI.
*/
@Test
public void testMissingDpi() {
Drawable.setDpi(new Resolution(320, 240, 60), new Config(new Resolution(1920, 1200, 16), 60, false));
try {
testImage(false);
testSprite(false);
testSpriteAnimated(false, 1, 1);
testSpriteTiled(false, 1, 1);
testSpriteFont(false, 1, 1);
testSpriteParallaxed(false, 1, 1, 1);
} finally {
Drawable.setDpi(null);
}
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class Sequence method setTime.
@Override
public void setTime(double factor) {
final double scale = UtilMath.clamp(factor, 0.1, 5.0);
final Resolution time = new Resolution(resolution.getWidth(), resolution.getHeight(), (int) (resolution.getRate() * scale));
loop.notifyRateChanged(time.getRate());
onRateChanged(time.getRate());
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class SequenceRenderer method getTransform.
/**
* Get the transform associated to the filter keeping screen scale independent.
*
* @return The associated transform instance.
*/
private Transform getTransform() {
final Resolution output = config.getOutput();
final double scaleY = output.getHeight() / (double) source.getHeight();
if (UtilMath.equals(output.getWidth() / (double) output.getHeight(), source.getWidth() / (double) source.getHeight(), SCALE_PRECISION)) {
return filter.getTransform(scaleY, scaleY);
}
final double scaleX = output.getWidth() / (double) source.getWidth();
return filter.getTransform(scaleX, scaleY);
}
Aggregations