Search in sources :

Example 21 with Graphic

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

the class FogOfWarTest method testRender.

/**
 * Test the fog of war render.
 */
@Test
void testRender() {
    Medias.setLoadFromJar(MapTileFog.class);
    fog.create(Medias.create("fog.xml"));
    Medias.setLoadFromJar(null);
    assertFalse(fog.hasFogOfWar());
    final Graphic g = Graphics.createGraphic();
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    fog.setTilesheet(new SpriteTiledMock(), null);
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    assertFalse(fog.hasFogOfWar());
    fog.setTilesheet(null, new SpriteTiledMock());
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    assertFalse(fog.hasFogOfWar());
    fog.setTilesheet(new SpriteTiledMock(), new SpriteTiledMock());
    fog.setEnabled(true, false);
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    assertTrue(fog.hasFogOfWar());
    fog.setTilesheet(new SpriteTiledMock(), new SpriteTiledMock());
    fog.setEnabled(false, true);
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    assertTrue(fog.hasFogOfWar());
    fog.setTilesheet(new SpriteTiledMock(), new SpriteTiledMock());
    fog.setEnabled(true, true);
    fog.renderTile(g, map.getTile(0, 0), 0, 0);
    assertTrue(fog.hasFogOfWar());
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.jupiter.api.Test)

Example 22 with Graphic

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

the class ScanlineCrt method prepare.

@Override
public void prepare(Config config) {
    final Resolution output = config.getOutput();
    scanline = cache.get(config);
    if (scanline == null) {
        final Media media = Medias.create(FOLDER_SCANLINE, FOLDER_CRT, output.getWidth() + Constant.UNDERSCORE + output.getHeight() + ".png");
        if (media.exists()) {
            scanline = Graphics.getImageBuffer(media);
        } else {
            scanline = Graphics.createImageBufferAlpha(output.getWidth(), output.getHeight());
            final Graphic g2 = scanline.createGraphic();
            create(g2, scanline.getWidth(), scanline.getHeight());
            g2.dispose();
            Graphics.saveImage(scanline, media);
        }
        cache.put(config, scanline);
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Media(com.b3dgs.lionengine.Media) Resolution(com.b3dgs.lionengine.Resolution)

Example 23 with Graphic

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

the class ScanlineHorizontal method prepare.

@Override
public void prepare(Config config) {
    final Resolution output = config.getOutput();
    scanline = cache.get(config);
    if (scanline == null) {
        final Media media = Medias.create(FOLDER_SCANLINE, FOLDER_HORIZONTAL, output.getWidth() + Constant.UNDERSCORE + output.getHeight() + ".png");
        if (media.exists()) {
            scanline = Graphics.getImageBuffer(media);
        } else {
            scanline = Graphics.createImageBufferAlpha(output.getWidth(), output.getHeight());
            final Graphic g2 = scanline.createGraphic();
            create(g2, scanline.getWidth(), scanline.getHeight());
            g2.dispose();
            Graphics.saveImage(scanline, media);
        }
        cache.put(config, scanline);
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Media(com.b3dgs.lionengine.Media) Resolution(com.b3dgs.lionengine.Resolution)

Example 24 with Graphic

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

the class MapTileCollisionRendererModel method createFunctionDraw.

/**
 * Create the function draw to buffer.
 *
 * @param collision The collision reference.
 * @param tw The tile width.
 * @param th The tile height.
 * @return The created collision representation buffer.
 */
public static ImageBuffer createFunctionDraw(CollisionFormula collision, int tw, int th) {
    final ImageBuffer buffer = Graphics.createImageBuffer(tw, th, ColorRgba.TRANSPARENT);
    final Graphic g = buffer.createGraphic();
    g.setColor(ColorRgba.PURPLE);
    createFunctionDraw(g, collision, tw, th);
    g.dispose();
    return buffer;
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Graphic(com.b3dgs.lionengine.graphic.Graphic)

Example 25 with Graphic

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

the class Sequence method render.

/**
 * Local render routine.
 */
private void render() {
    if (screen.isReady()) {
        final Graphic g = screen.getGraphic();
        if (directRendering) {
            render(g);
        } else {
            render(graphic);
            g.drawImage(filter.filter(buf), transform, 0, 0);
        }
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic)

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