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