use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class RasterableModel method setRaster.
@Override
public void setRaster(boolean save, Media media, int rasterHeight, Collection<Integer> allowed) {
if (setupRastered.isExtern()) {
Check.notNull(media);
Check.superiorStrict(rasterHeight, 0);
this.media = Optional.of(media);
this.rasterHeight = rasterHeight;
setupRastered.load(save, media, allowed);
rastersAnim.clear();
count = -1;
final List<ImageBuffer> buffers = setupRastered.getRasters();
final int n = buffers.size();
for (int i = 0; i < n; i++) {
final SpriteAnimated sprite = Drawable.loadSpriteAnimated(buffers.get(i), raster.getFramesHorizontal(), raster.getFramesVertical());
rastersAnim.add(sprite);
count++;
}
if (rastersAnim.size() < 2) {
updater = UpdatableVoid.getInstance();
} else {
updater = extrp -> updateRasterAnim();
}
}
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class ImageBufferHeadlessTest method testImage.
/**
* Test image.
*/
@Test
void testImage() {
final ImageBuffer image = new ImageBufferHeadless(100, 100, Transparency.OPAQUE);
assertNotNull(image.createGraphic());
image.prepare();
assertEquals(ColorRgba.TRANSPARENT.getRgba(), image.getRgb(0, 0));
assertNotNull(image.getRgb(0, 0, 1, 1, new int[1], 0, 0));
assertEquals(Transparency.OPAQUE, image.getTransparency());
assertEquals(Transparency.OPAQUE, new ImageBufferHeadless(100, 100, Transparency.OPAQUE).getTransparency());
assertEquals(100, image.getWidth());
assertEquals(100, image.getHeight());
image.setRgb(0, 0, ColorRgba.BLUE.getRgba());
assertEquals(ColorRgba.BLUE.getRgba(), image.getRgb(0, 0));
image.setRgb(0, 0, 0, 0, new int[1], 0, 0);
image.dispose();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class GraphicHeadlessTest method testApplyMask.
/**
* Test apply mask.
*/
@Test
void testApplyMask() {
final ImageBuffer image = Graphics.createImageBuffer(10, 20);
assertEquals(ColorRgba.BLACK.getRgba(), Graphics.applyMask(image, ColorRgba.TRANSPARENT).getRgb(0, 0));
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class TextHeadlessTest method beforeTests.
/**
* Setup tests.
*/
@BeforeAll
public static void beforeTests() {
Graphics.setFactoryGraphic(new FactoryGraphicHeadless());
final ImageBuffer buffer = Graphics.createImageBuffer(320, 240);
buffer.prepare();
g = buffer.createGraphic();
}
use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.
the class SpriteDigitTest method testEquals.
/**
* Test equals.
*/
@Test
void testEquals() {
final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
final SpriteDigit sprite = new SpriteDigitImpl(surface, 1, 1, 1);
final Media media = Medias.create("image.png");
final SpriteDigit spriteMedia = new SpriteDigitImpl(media, 1, 1, 1);
assertEquals(sprite, sprite);
assertEquals(sprite, new SpriteDigitImpl(surface, 1, 1, 1));
assertEquals(spriteMedia, spriteMedia);
assertNotEquals(sprite, null);
assertNotEquals(sprite, new Object());
assertNotEquals(sprite, new SpriteDigitImpl(media, 1, 1, 1));
assertNotEquals(spriteMedia, new SpriteDigitImpl(media, 1, 1, 1));
assertNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(64, 32), 1, 1, 1));
assertNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(32, 32), 1, 1, 1));
assertNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(64, 64), 1, 1, 1));
assertNotEquals(sprite, new SpriteDigitImpl(Graphics.createImageBuffer(32, 64), 1, 1, 1));
sprite.dispose();
spriteMedia.dispose();
surface.dispose();
}
Aggregations