use of com.b3dgs.lionengine.graphic.SpriteFont in project lionengine by b3dgs.
the class SpriteFontTest method testStretchInvalidWidth.
/**
* Test stretch sprite with invalid width.
*/
@Test(expected = LionEngineException.class)
public void testStretchInvalidWidth() {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.stretch(0.0, 100.0);
}
use of com.b3dgs.lionengine.graphic.SpriteFont in project lionengine by b3dgs.
the class SpriteFontTest method testStretchInvalidHeight.
/**
* Test stretch sprite with invalid height.
*/
@Test(expected = LionEngineException.class)
public void testStretchInvalidHeight() {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.stretch(100, 0.0);
}
use of com.b3dgs.lionengine.graphic.SpriteFont in project lionengine by b3dgs.
the class SpriteFontTest method testStretch.
/**
* Test stretch sprite.
*/
@Test
public void testStretch() {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.load();
sprite.stretch(100.0, 100.0);
Assert.assertEquals(64, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
sprite.stretch(200.0, 100.0);
Assert.assertEquals(130, sprite.getWidth());
Assert.assertEquals(32, sprite.getHeight());
sprite.stretch(100.0, 200.0);
Assert.assertEquals(130, sprite.getWidth());
Assert.assertEquals(64, sprite.getHeight());
sprite.stretch(200.0, 200.0);
Assert.assertEquals(260, sprite.getWidth());
Assert.assertEquals(128, sprite.getHeight());
}
use of com.b3dgs.lionengine.graphic.SpriteFont in project lionengine by b3dgs.
the class SpriteFontTest method testGetTextHeight.
/**
* Test get text height.
*/
@Test
public void testGetTextHeight() {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.load();
Assert.assertEquals(8, sprite.getTextHeight("az"));
Assert.assertEquals(16, sprite.getTextHeight("az%az"));
}
use of com.b3dgs.lionengine.graphic.SpriteFont in project lionengine by b3dgs.
the class SpriteFontTest method testRender.
/**
* Test render.
*/
@Test
public void testRender() {
final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
try {
final SpriteFont sprite = new SpriteFontImpl(media, font, 6, 7);
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);
} finally {
g.dispose();
}
}
Aggregations