Search in sources :

Example 11 with Sprite

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

the class SpriteTest method testStretch.

/**
 * Test stretch sprite.
 */
@Test
public void testStretch() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.stretch(100.0, 100.0);
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    sprite.stretch(200.0, 100.0);
    Assert.assertEquals(128, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
    sprite.stretch(100.0, 200.0);
    Assert.assertEquals(128, sprite.getWidth());
    Assert.assertEquals(64, sprite.getHeight());
    sprite.stretch(200.0, 200.0);
    Assert.assertEquals(256, sprite.getWidth());
    Assert.assertEquals(128, sprite.getHeight());
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 12 with Sprite

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

the class SpriteTest method testSetAlphaLow.

/**
 * Test set alpha too low.
 */
@Test(expected = LionEngineException.class)
public void testSetAlphaLow() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setAlpha(-1);
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 13 with Sprite

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

the class SpriteTest method testMirrorNull.

/**
 * Test mirror <code>null</code>.
 */
@Test(expected = LionEngineException.class)
public void testMirrorNull() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    sprite.setMirror(null);
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 14 with Sprite

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

the class SpriteTest method testSetAlpha.

/**
 * Test set alpha.
 */
@Test
public void testSetAlpha() {
    final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
    for (int alpha = 0; alpha < 256; alpha++) {
        sprite.setAlpha(alpha);
        Assert.assertEquals(64, sprite.getWidth());
        Assert.assertEquals(32, sprite.getHeight());
    }
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 15 with Sprite

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

the class SpriteTest method testRender.

/**
 * Test render.
 */
@Test
public void testRender() {
    final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
    try {
        final Sprite sprite = new SpriteImpl(Graphics.createImageBuffer(64, 32));
        sprite.render(g);
        sprite.setMirror(Mirror.HORIZONTAL);
        sprite.render(g);
        sprite.setMirror(Mirror.VERTICAL);
        sprite.render(g);
    } finally {
        g.dispose();
    }
}
Also used : Sprite(com.b3dgs.lionengine.graphic.Sprite) Graphic(com.b3dgs.lionengine.graphic.Graphic) Test(org.junit.Test)

Aggregations

Sprite (com.b3dgs.lionengine.graphic.Sprite)22 Test (org.junit.Test)22 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)3 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1