use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class Sequence method initResolution.
/**
* Initialize resolution.
*
* @param source The resolution source (must not be <code>null</code>).
* @throws LionEngineException If invalid argument.
*/
private void initResolution(Resolution source) {
Check.notNull(source);
config.setSource(source);
screen.onSourceChanged(source);
// Store source size
final int width = source.getWidth();
final int height = source.getHeight();
// Standard rendering
final Resolution output = config.getOutput();
if (FilterNone.INSTANCE.equals(filter) && source.getWidth() == output.getWidth() && source.getHeight() == output.getHeight()) {
buf = null;
transform = null;
directRendering = true;
} else // Scaled rendering
{
buf = Graphics.createImageBuffer(width, height);
transform = getTransform(filter);
final Graphic gbuf = buf.createGraphic();
graphic.setGraphic(gbuf.getGraphic());
directRendering = false;
}
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class FactoryGraphicAwt method createImageBuffer.
@Override
public ImageBuffer createImageBuffer(int width, int height, ColorRgba transparency) {
Check.notNull(transparency);
final BufferedImage image = ToolsAwt.createImage(width, height, java.awt.Transparency.BITMASK);
final ImageBuffer buffer = new ImageBufferAwt(image);
final Graphic g = buffer.createGraphic();
g.setColor(transparency);
g.drawRect(0, 0, width, height, true);
g.dispose();
return buffer;
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class CursorTest method testCursor.
/**
* Test the cursor class.
*/
@Test
public void testCursor() {
final Graphic g = new GraphicMock();
final MouseMock mouse = new MouseMock();
final Cursor cursor = new Cursor();
cursor.addImage(0, Medias.create("cursor.png"));
cursor.setArea(0, 0, 320, 240);
cursor.setSensibility(1.0, 2.0);
cursor.setInputDevice(mouse);
cursor.setSurfaceId(0);
cursor.update(1.0);
cursor.setSyncMode(true);
Assert.assertTrue(cursor.isSynchronized());
cursor.update(1.0);
cursor.setSyncMode(false);
Assert.assertTrue(!cursor.isSynchronized());
cursor.update(1.0);
cursor.setSyncMode(true);
cursor.update(1.0);
cursor.setLocation(10, 20);
Assert.assertEquals(0.0, cursor.getX(), 0.000001);
Assert.assertEquals(0.0, cursor.getY(), 0.000001);
Assert.assertEquals(10.0, cursor.getScreenX(), 0.000001);
Assert.assertEquals(20.0, cursor.getScreenY(), 0.000001);
Assert.assertEquals(1.0, cursor.getSensibilityHorizontal(), 0.000001);
Assert.assertEquals(2.0, cursor.getSensibilityVertical(), 0.000001);
cursor.setRenderingOffset(0, 0);
Assert.assertEquals(Integer.valueOf(0), cursor.getSurfaceId());
Assert.assertEquals(0, cursor.getClick());
cursor.render(g);
}
use of com.b3dgs.lionengine.graphic.Graphic 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();
}
}
use of com.b3dgs.lionengine.graphic.Graphic in project lionengine by b3dgs.
the class SpriteTiledTest method testRender.
/**
* Test render.
*/
@Test
public void testRender() {
final Graphic g = Graphics.createImageBuffer(100, 100).createGraphic();
try {
final SpriteTiled sprite = new SpriteTiledImpl(Graphics.createImageBuffer(64, 32), 16, 8);
sprite.render(g);
sprite.setTile(0);
sprite.setMirror(Mirror.HORIZONTAL);
sprite.render(g);
sprite.setMirror(Mirror.VERTICAL);
sprite.render(g);
} finally {
g.dispose();
}
}
Aggregations