use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class SpriteTiledTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
public void testSetLocationViewer() {
final SpriteTiledImpl sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
final ViewerMock viewer = new ViewerMock();
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(1.5, sprite.getX(), UtilTests.PRECISION);
Assert.assertEquals(237.5, sprite.getY(), UtilTests.PRECISION);
Assert.assertEquals(1, sprite.getRenderX());
Assert.assertEquals(237, sprite.getRenderY());
viewer.set(10, 20);
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(-8.5, sprite.getX(), UtilTests.PRECISION);
Assert.assertEquals(257.5, sprite.getY(), UtilTests.PRECISION);
Assert.assertEquals(-9, sprite.getRenderX());
Assert.assertEquals(257, sprite.getRenderY());
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class ImageTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
public void testSetLocationViewer() {
final ImageImpl image = new ImageImpl(Graphics.createImageBuffer(64, 32));
final ViewerMock viewer = new ViewerMock();
image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(1.5, image.getX(), UtilTests.PRECISION);
Assert.assertEquals(237.5, image.getY(), UtilTests.PRECISION);
Assert.assertEquals(1, image.getRenderX());
Assert.assertEquals(237, image.getRenderY());
viewer.set(10, 20);
image.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(-8.5, image.getX(), UtilTests.PRECISION);
Assert.assertEquals(257.5, image.getY(), UtilTests.PRECISION);
Assert.assertEquals(-9, image.getRenderX());
Assert.assertEquals(257, image.getRenderY());
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class SpriteFontTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
public void testSetLocationViewer() {
final SpriteFontImpl sprite = new SpriteFontImpl(media, font, 6, 7);
sprite.load();
final ViewerMock viewer = new ViewerMock();
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(0.0, sprite.getX(), UtilTests.PRECISION);
Assert.assertEquals(0.0, sprite.getY(), UtilTests.PRECISION);
viewer.set(10, 20);
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
Assert.assertEquals(0.0, sprite.getX(), UtilTests.PRECISION);
Assert.assertEquals(0.0, sprite.getY(), UtilTests.PRECISION);
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class SpriteAnimatedTest method testSetLocationViewer.
/**
* Test set location with viewer.
*/
@Test
void testSetLocationViewer() {
final SpriteAnimatedImpl sprite = new SpriteAnimatedImpl(Graphics.createImageBuffer(64, 32), 16, 8);
final ViewerMock viewer = new ViewerMock();
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(1.5, sprite.getX());
assertEquals(237.5, sprite.getY());
assertEquals(2, sprite.getRenderX());
assertEquals(238, sprite.getRenderY());
viewer.set(10, 20);
sprite.setLocation(viewer, Geom.createLocalizable(1.5, 2.5));
assertEquals(-8.5, sprite.getX());
assertEquals(257.5, sprite.getY());
assertEquals(-8, sprite.getRenderX());
assertEquals(258, sprite.getRenderY());
}
use of com.b3dgs.lionengine.ViewerMock in project lionengine by b3dgs.
the class GraphicTest method testGraphic.
/**
* Test graphic.
*/
@Test
protected void testGraphic() {
final ImageBuffer image = Graphics.createImageBuffer(320, 240);
final Graphic g = image.createGraphic();
assertNotNull(g.getGraphic());
g.clear(0, 0, image.getWidth(), image.getHeight());
g.copyArea(0, 0, image.getWidth(), image.getHeight(), 0, 0);
g.drawImage(image, 0, 0);
final Transform transform = Graphics.createTransform();
g.drawImage(image, transform, 0, 0);
g.drawImage(image, transform, 0, 0);
g.drawImage(image, 0, 0, 0, 0, 0, 0, 0, 0);
g.drawImage(image, 0, 0, 0, 0, 2, 0, 0, 0);
g.drawImage(image, 0, 0, 0, 0, 2, 0, 0, 0);
g.drawImage(image, 0, 0, 0, 0, 2, 0, 0, 0, 0, 20, 30);
g.drawImage(image, 0, 0, 0, 0, 2, 0, 0, 0, 10, 20, 30);
g.drawLine(0, 0, 0, 0);
g.drawOval(0, 0, image.getWidth(), image.getHeight(), true);
g.drawOval(0, 0, image.getWidth(), image.getHeight(), false);
g.drawRect(0, 0, 1, 0, true);
g.drawRect(0, 0, 0, 1, true);
g.drawRect(0, 0, 0, 0, true);
g.drawRect(0, 0, image.getWidth(), image.getHeight(), true);
g.drawRect(0, 0, image.getWidth(), image.getHeight(), false);
assertEquals(ColorRgba.WHITE.getRgba(), g.getColor().getRgba());
g.setColor(ColorRgba.BLUE);
g.setColor(ColorRgba.BLUE);
assertEquals(ColorRgba.BLUE.getRgba(), g.getColor().getRgba());
g.setColorGradient(new ColorGradient(0, 0, ColorRgba.CYAN, 100, 100, ColorRgba.RED));
g.setColorGradient(new ColorGradient(0, 0, ColorRgba.CYAN, 100, 100, ColorRgba.RED));
g.drawGradient(0, 0, 100, 100);
g.drawLine(new ViewerMock(), 1, 2, 3, 4);
g.drawLine(new ViewerMock(), 1, 3, 2, 4);
g.drawLine(new ViewerMock(), 1, 2, 2, 1);
g.drawLine(new ViewerMock(), 4, 3, 2, 3);
g.drawOval(new ViewerMock(), Origin.BOTTOM_LEFT, 0, 0, image.getWidth(), image.getHeight(), true);
g.drawRect(new ViewerMock(), Origin.BOTTOM_LEFT, 0, 0, image.getWidth(), image.getHeight(), true);
g.drawRect(new ViewerMock(), Origin.BOTTOM_LEFT, Geom.createArea(0, 0, image.getWidth(), image.getHeight()), true);
g.drawGradient(new ViewerMock(), Origin.BOTTOM_LEFT, 0, 0, 100, 100);
g.dispose();
g.setGraphic(null);
assertNull(g.getGraphic());
image.dispose();
}
Aggregations