Search in sources :

Example 36 with Graphic

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

the class TextAwtTest method testAlignUnknown.

/**
 * Test align unknown.
 */
@Test
void testAlignUnknown() {
    final Text text = Graphics.createText(Constant.FONT_DIALOG, 12, TextStyle.NORMAL);
    final Graphic g = Graphics.createGraphic();
    g.setGraphic(ToolsAwt.createImage(1, 1, java.awt.Transparency.OPAQUE).createGraphics());
    assertThrows(() -> text.draw(g, 0, 0, Align.values()[3], Constant.EMPTY_STRING), "Unknown enum: FAIL");
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Text(com.b3dgs.lionengine.graphic.Text) Test(org.junit.jupiter.api.Test)

Example 37 with Graphic

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

the class SequenceRenderer method initResolution.

/**
 * Initialize resolution.
 *
 * @param source The resolution source (must not be <code>null</code>).
 * @throws LionEngineException If invalid argument.
 */
void initResolution(Resolution source) {
    Check.notNull(source);
    setSystemCursorVisible(cursorVisibility.booleanValue());
    this.source = source;
    screen.onSourceChanged(source);
    w = source.getWidth();
    h = source.getHeight();
    buf = Graphics.createImageBuffer(w, h);
    bu = new int[w * h];
    transform = getTransform();
    final Graphic gbuf = buf.createGraphic();
    graphic.setGraphic(gbuf.getGraphic());
    scanline.prepare(config);
    setDirect(h == config.getOutput().getHeight());
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic)

Example 38 with Graphic

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

the class SpriteFontTest method testDraw.

/**
 * Test draw.
 */
@Test
void testDraw() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
    sprite.load();
    sprite.draw(g, 1, 2, Align.CENTER, "az%");
    g.dispose();
    sprite.dispose();
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 39 with Graphic

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

the class SpriteFontTest method testRender.

/**
 * Test render.
 */
@Test
void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
    sprite.load();
    sprite.prepare();
    sprite.render(g);
    sprite.setMirror(Mirror.HORIZONTAL);
    sprite.setAlign(Align.RIGHT);
    sprite.setText("az%");
    sprite.setLocation(1.5, 2.5);
    sprite.render(g);
    sprite.setMirror(Mirror.VERTICAL);
    sprite.setLineHeight(5);
    sprite.render(g);
    g.dispose();
    sprite.dispose();
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 40 with Graphic

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

the class SpriteTest method testRender.

/**
 * Test render.
 */
@Test
void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.render(g);
    sprite.setMirror(Mirror.HORIZONTAL);
    sprite.render(g);
    sprite.setMirror(Mirror.VERTICAL);
    sprite.render(g);
    g.dispose();
}
Also used : 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