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());
}
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);
}
}
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);
}
}
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;
}
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);
}
}
}
Aggregations