Search in sources :

Example 16 with ImageBuffer

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

the class GraphicsTest method testResize.

/**
 * Test resize.
 */
@Test
public void testResize() {
    final ImageBuffer resized = Graphics.resize(image, 1, 2);
    Assert.assertNotEquals(image, resized);
    Assert.assertEquals(1, resized.getWidth());
    Assert.assertEquals(2, resized.getHeight());
    resized.dispose();
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) GraphicTest(com.b3dgs.lionengine.graphic.GraphicTest) Test(org.junit.Test)

Example 17 with ImageBuffer

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

the class GraphicsTest method testGetRasterBuffer.

/**
 * Test save image.
 */
@Test
public void testGetRasterBuffer() {
    final ImageBuffer raster = Graphics.getRasterBuffer(image, 0, 0, 0, 255, 255, 255, 5);
    Assert.assertNotEquals(image, raster);
    Assert.assertEquals(image.getWidth(), raster.getWidth());
    Assert.assertEquals(image.getHeight(), raster.getHeight());
    raster.dispose();
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) GraphicTest(com.b3dgs.lionengine.graphic.GraphicTest) Test(org.junit.Test)

Example 18 with ImageBuffer

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

the class SpriteAnimatedTest method testHashCode.

/**
 * Test hash code.
 */
@Test
public void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final int sprite = new SpriteAnimatedImpl(surface, 16, 8).hashCode();
    final SpriteAnimated spriteMedia = new SpriteAnimatedImpl(media, 16, 8);
    spriteMedia.load();
    Assert.assertEquals(sprite, new SpriteAnimatedImpl(surface, 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new Object().hashCode());
    Assert.assertNotEquals(spriteMedia.hashCode(), new SpriteAnimatedImpl(media, 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 32), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 64), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 64), 16, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 8, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 16).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(32, 32), 8, 8).hashCode());
    Assert.assertNotEquals(sprite, new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 64), 16, 16).hashCode());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) SpriteAnimated(com.b3dgs.lionengine.graphic.SpriteAnimated) Test(org.junit.Test)

Example 19 with ImageBuffer

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

the class SpriteTest method testEquals.

/**
 * Test equals.
 */
@Test
public void testEquals() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Sprite sprite = new SpriteImpl(surface);
    final Sprite spriteMedia = new SpriteImpl(media);
    spriteMedia.load();
    Assert.assertEquals(sprite, sprite);
    Assert.assertEquals(sprite, new SpriteImpl(surface));
    Assert.assertEquals(spriteMedia, spriteMedia);
    Assert.assertNotEquals(sprite, null);
    Assert.assertNotEquals(sprite, new Object());
    Assert.assertNotEquals(sprite, new SpriteImpl(media));
    Assert.assertNotEquals(spriteMedia, new SpriteImpl(media));
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 32)));
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 32)));
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 64)));
    Assert.assertNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 64)));
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Example 20 with ImageBuffer

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

the class SpriteTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
public void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Sprite sprite = new SpriteImpl(surface);
    Assert.assertTrue(sprite.isLoaded());
    Assert.assertEquals(surface, sprite.getSurface());
    Assert.assertEquals(64, sprite.getWidth());
    Assert.assertEquals(32, sprite.getHeight());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Sprite(com.b3dgs.lionengine.graphic.Sprite) Test(org.junit.Test)

Aggregations

ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)110 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)28 Media (com.b3dgs.lionengine.Media)16 Graphic (com.b3dgs.lionengine.graphic.Graphic)12 GraphicTest (com.b3dgs.lionengine.graphic.GraphicTest)12 FactoryGraphic (com.b3dgs.lionengine.graphic.FactoryGraphic)9 BufferedImage (java.awt.image.BufferedImage)9 SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)6 SpriteTiled (com.b3dgs.lionengine.graphic.drawable.SpriteTiled)5 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)3 FactoryGraphicTest (com.b3dgs.lionengine.graphic.FactoryGraphicTest)3 Image (com.b3dgs.lionengine.graphic.Image)3 Sprite (com.b3dgs.lionengine.graphic.Sprite)3 SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 TilesExtractor (com.b3dgs.lionengine.game.feature.tile.TilesExtractor)2 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Config (com.b3dgs.lionengine.Config)1