use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class SpriteFontTest method testDraw.
/**
* Test draw.
*/
@Test
public void testDraw() {
final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
try {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.load();
sprite.draw(g, 1, 2, Align.CENTER, "az%");
} finally {
g.dispose();
}
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class TilesExtractor method extract.
/**
* Extract the tile from level.
*
* @param level The level image reference.
* @param number The tile number on level.
* @return The extracted tile image from level.
*/
private static ImageBuffer extract(SpriteTiled level, int number) {
final ColorRgba transparency = level.getSurface().getTransparentColor();
final ImageBuffer tile = Graphics.createImageBuffer(level.getTileWidth(), level.getTileHeight(), transparency);
final Graphic g = tile.createGraphic();
level.setTile(number);
level.render(g);
g.dispose();
final ImageBuffer copy = Graphics.getImageBuffer(tile);
tile.dispose();
return copy;
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class Minimap method prepare.
/**
* Fill minimap surface with tile color configuration.
*
* @throws LionEngineException If surface has not been loaded ({@link #load()} may have not been called).
*/
@Override
public void prepare() {
if (surface == null) {
throw new LionEngineException(ERROR_SURFACE);
}
final Graphic g = surface.createGraphic();
final int v = map.getInTileHeight();
final int h = map.getInTileWidth();
for (int ty = 0; ty < v; ty++) {
for (int tx = 0; tx < h; tx++) {
final Tile tile = map.getTile(tx, ty);
final ColorRgba color = getTileColor(tile);
if (!NO_TILE.equals(color)) {
g.setColor(color);
g.drawRect(tx, v - ty - 1, 0, 0, false);
}
}
}
g.dispose();
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class SpriteDigitTest method testRender.
/**
* Test render.
*/
@Test
void testRender() {
final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
final SpriteDigit sprite = new SpriteDigitImpl(Graphics.createImageBuffer(64, 32), 1, 1, 1);
sprite.render(g);
sprite.setMirror(Mirror.HORIZONTAL);
sprite.render(g);
sprite.setMirror(Mirror.VERTICAL);
sprite.render(g);
g.dispose();
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class SpriteTiledTest method testRender.
/**
* Test render.
*/
@Test
void testRender() {
final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
try {
final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.render(g);
sprite.setTile(0);
sprite.setMirror(Mirror.HORIZONTAL);
sprite.render(g);
sprite.setMirror(Mirror.VERTICAL);
sprite.render(g);
} finally {
g.dispose();
}
}
Aggregations