Search in sources :

Example 41 with Graphic

use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.

the class ImageTest method testRender.

/**
 * Test the render.
 */
@Test
void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    final Image image = new ImageImpl(Graphics.createImageBuffer(64, 32));
    image.render(g);
    g.dispose();
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 42 with Graphic

use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.

the class SpriteAnimatedTest method testRender.

/**
 * Test render.
 */
@Test
void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    try {
        final SpriteAnimated sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
        sprite.render(g);
        sprite.setFrame(1);
        sprite.setMirror(Mirror.HORIZONTAL);
        sprite.render(g);
        sprite.setMirror(Mirror.VERTICAL);
        sprite.render(g);
    } finally {
        g.dispose();
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 43 with Graphic

use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.

the class CursorTest method testRenderNoSurface.

/**
 * Test render no surface
 */
@Test
void testRenderNoSurface() {
    final Graphic g = Graphics.createGraphic();
    final Cursor cursor = new Cursor(services);
    cursor.setVisible(false);
    cursor.render(g);
    cursor.setVisible(true);
    assertThrowsNpe(() -> cursor.render(g));
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 44 with Graphic

use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.

the class CursorTest method testRender.

/**
 * Test render
 */
@Test
void testRender() {
    final Cursor cursor = new Cursor(services);
    cursor.addImage(0, Medias.create("cursor.png"));
    cursor.load();
    final Graphic g = Graphics.createGraphic();
    cursor.render(g);
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 45 with Graphic

use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.

the class TextGameTest method testSize.

/**
 * Test size.
 */
@Test
void testSize() {
    final Graphic g = new GraphicMock();
    final TextGame text = new TextGame(Constant.FONT_DIALOG, 8, TextStyle.NORMAL);
    assertEquals(8, text.getSize());
    assertEquals(0, text.getWidth());
    assertEquals(0, text.getHeight());
    assertEquals(0, text.getStringWidth(g, "text"));
    assertEquals(0, text.getStringHeight(g, "text"));
    g.dispose();
}
Also used : GraphicMock(com.b3dgs.lionengine.graphic.GraphicMock) FactoryGraphicMock(com.b3dgs.lionengine.graphic.FactoryGraphicMock) Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Aggregations

Graphic (com.b3dgs.lionengine.graphic.Graphic)45 Test (org.junit.jupiter.api.Test)18 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)12 FactoryGraphic (com.b3dgs.lionengine.graphic.FactoryGraphic)9 Test (org.junit.Test)8 BufferedImage (java.awt.image.BufferedImage)5 GraphicMock (com.b3dgs.lionengine.graphic.GraphicMock)4 LionEngineException (com.b3dgs.lionengine.LionEngineException)3 Resolution (com.b3dgs.lionengine.Resolution)3 FactoryGraphicMock (com.b3dgs.lionengine.graphic.FactoryGraphicMock)3 Media (com.b3dgs.lionengine.Media)2 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)2 SpriteFont (com.b3dgs.lionengine.graphic.SpriteFont)2 Text (com.b3dgs.lionengine.graphic.Text)2 Align (com.b3dgs.lionengine.Align)1 Surface (com.b3dgs.lionengine.Surface)1 Tile (com.b3dgs.lionengine.game.feature.tile.Tile)1 Image (com.b3dgs.lionengine.graphic.Image)1 Sprite (com.b3dgs.lionengine.graphic.Sprite)1 SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)1