Class Canvas
- java.lang.Object
-
- nl.colorize.multimedialib.renderer.Canvas
-
public class Canvas extends java.lang.ObjectUsed to control the size of the canvas displaying the application's graphics, independent from the size of the screen. This allows the application to control the zoom level, therefore controlling the user experience in situations where the same application is used across a variety of devices with different screen sizes. This class allows to translate between the two coordinate systems.Although the canvas is given a preferred size and aspect ratio upon creation, it is not guaranteed that these will ever be used. This is especially true for mobile apps, where the application will usually fill the entire screen.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetHeight()intgetScreenHeight()intgetScreenWidth()intgetWidth()floatgetZoomLevel()voidoffset(int offsetX, int offsetY)voidresize(int screenWidth, int screenHeight)Sets the screen dimensions to the specified values.inttoCanvasX(int screenX)inttoCanvasY(int screenY)inttoScreenX(float canvasX)inttoScreenY(float canvasY)
-
-
-
Method Detail
-
resize
public void resize(int screenWidth, int screenHeight)Sets the screen dimensions to the specified values. This method should be called by the renderer when the application window is first created, and whenever the window is resized.
-
offset
public void offset(int offsetX, int offsetY)
-
getWidth
public int getWidth()
-
getHeight
public int getHeight()
-
getScreenWidth
public int getScreenWidth()
-
getScreenHeight
public int getScreenHeight()
-
getZoomLevel
public float getZoomLevel()
-
toCanvasX
public int toCanvasX(int screenX)
-
toCanvasY
public int toCanvasY(int screenY)
-
toScreenX
public int toScreenX(float canvasX)
-
toScreenY
public int toScreenY(float canvasY)
-
-