Search in sources :

Example 11 with SpriteFont

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);
}
Also used : SpriteFont(com.b3dgs.lionengine.graphic.SpriteFont) Test(org.junit.Test)

Example 12 with SpriteFont

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);
}
Also used : SpriteFont(com.b3dgs.lionengine.graphic.SpriteFont) Test(org.junit.Test)

Example 13 with SpriteFont

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());
}
Also used : SpriteFont(com.b3dgs.lionengine.graphic.SpriteFont) Test(org.junit.Test)

Example 14 with SpriteFont

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"));
}
Also used : SpriteFont(com.b3dgs.lionengine.graphic.SpriteFont) Test(org.junit.Test)

Example 15 with SpriteFont

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();
    }
}
Also used : SpriteFont(com.b3dgs.lionengine.graphic.SpriteFont) Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.Test)

Aggregations

SpriteFont (com.b3dgs.lionengine.graphic.SpriteFont)22 Test (org.junit.Test)22 Graphic (com.b3dgs.lionengine.graphic.Graphic)2 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1