use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class ParallaxTest method testParallax.
/**
* Test clouds.
*/
@Test
void testParallax() {
final Parallax parallax = new Parallax(new SourceResolutionProvider() {
@Override
public int getWidth() {
return 320;
}
@Override
public int getHeight() {
return 240;
}
@Override
public int getRate() {
return 60;
}
}, Medias.create("surface.png"), 11, 1, 2, 100, 100);
parallax.setScreenSize(320, 240);
parallax.update(1.0, 1, 0, 200.0);
parallax.update(1.0, 1, 200, 200.0);
parallax.update(1.0, 1, 300, 200.0);
parallax.update(1.0, 1, 0, -200.0);
parallax.update(1.0, 1, 0, -200.0);
parallax.update(1.0, 1, 0, -200.0);
final Graphic g = Graphics.createGraphic();
parallax.render(g);
g.dispose();
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class CloudsTest method testClouds.
/**
* Test clouds.
*/
@Test
void testClouds() {
final CloudsAbstract clouds = new CloudsAbstract(Medias.create("surface.png"), 7, 1, 10, 0) {
};
clouds.setY(0, 1);
clouds.setScreenWidth(20);
clouds.setSpeed(0, 2);
clouds.update(1.0, 1, 2, 3.0);
final Graphic g = Graphics.createGraphic();
clouds.render(g);
g.dispose();
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class BarTest method testBar.
/**
* Test the bar class.
*/
@Test
void testBar() {
final Graphic g = new GraphicMock();
final Bar bar = new Bar(10, 20);
bar.setBorderSize(1, 1);
bar.setColorBackground(ColorRgba.WHITE);
bar.setColorForeground(ColorRgba.BLACK);
bar.setLocation(0, 0);
bar.setMaximumSize(10, 20);
bar.setVerticalReferential(true);
bar.setHorizontalReferential(true);
bar.setWidthPercent(100);
bar.setHeightPercent(100);
assertEquals(10, bar.getWidthMax());
assertEquals(20, bar.getHeightMax());
assertEquals(100, bar.getWidthPercent());
assertEquals(100, bar.getHeightPercent());
assertEquals(10, bar.getWidth());
assertEquals(20, bar.getHeight());
bar.setWidthPercent(50);
bar.setHeightPercent(50);
assertEquals(50, bar.getWidthPercent());
assertEquals(50, bar.getHeightPercent());
assertEquals(5, bar.getWidth());
assertEquals(10, bar.getHeight());
bar.render(g);
bar.setColorBackground(null);
bar.setVerticalReferential(false);
bar.setHorizontalReferential(true);
bar.render(g);
bar.setColorBackground(ColorRgba.WHITE);
bar.setColorForeground(null);
bar.setVerticalReferential(false);
bar.setHorizontalReferential(false);
bar.render(g);
bar.setColor(null, null);
bar.setVerticalReferential(true);
bar.setHorizontalReferential(false);
bar.render(g);
bar.setWidthPercent(100);
bar.setHeightPercent(0);
bar.render(g);
bar.setWidthPercent(0);
bar.setHeightPercent(100);
bar.render(g);
bar.setWidthPercent(100);
bar.setHeightPercent(100);
bar.setColorGradient(0, 0, ColorRgba.WHITE, 50, 10, ColorRgba.BLACK);
bar.render(g);
bar.setColorGradient(ColorRgba.WHITE, ColorRgba.BLACK);
bar.render(g);
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class TimedMessageTest method testRender.
/**
* Test render.
*/
@Test
void testRender() {
final TimedMessage message = new TimedMessage(Graphics.createText(Constant.FONT_DIALOG, 8, TextStyle.NORMAL));
message.addMessage("test", 0, 0, 0L);
final Graphic g = Graphics.createGraphic();
message.render(g);
message.update(1.0);
message.render(g);
g.dispose();
assertFalse(message.hasMessage());
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class TextGameTest method testDraw.
/**
* Test draw.
*/
@Test
void testDraw() {
final Graphic g = new GraphicMock();
final TextGame text = new TextGame(Constant.FONT_DIALOG, 8, TextStyle.NORMAL);
text.setText("text");
text.setAlign(Align.CENTER);
text.setColor(ColorRgba.WHITE);
text.render(g);
text.draw(g, 0, 0, "toto");
text.draw(g, 1, 2, Align.LEFT, "tata");
text.draw(g, Geom.createLocalizable(3, 4), 1, 2, Align.RIGHT, "titi");
text.drawRect(g, ColorRgba.BLACK, 0, 0, 10, 20);
g.dispose();
}
Aggregations