java.lang.Object
technology.sola.engine.graphics.screen.Viewport
Viewport contains various information about the current viewport used. This is primarily used to keep track of the
correct
AspectRatioSizing based on the current AspectMode and screen width and height.-
Constructor Summary
ConstructorsConstructorDescriptionViewport(int canvasWidth, int canvasHeight) Creates an instance of the viewport given the canvas's width and height. -
Method Summary
Modifier and TypeMethodDescriptionfloatfloatvoidresize(int screenWidth, int screenHeight) Recalculates theAspectRatioSizingusing the currentAspectModeand the new screen width and height.voidsetAspectMode(AspectMode aspectMode) Updates theAspectModeused and recalculatesAspectRatioSizing.
-
Constructor Details
-
Viewport
public Viewport(int canvasWidth, int canvasHeight) Creates an instance of the viewport given the canvas's width and height.- Parameters:
canvasWidth- the width of the canvas (renderer)canvasHeight- the height of the canvas (renderer)
-
-
Method Details
-
getAspectMode
- Returns:
- the current
AspectMode
-
setAspectMode
Updates theAspectModeused and recalculatesAspectRatioSizing.- Parameters:
aspectMode- the newAspectMode
-
getAspectRatioSizing
- Returns:
- the current
AspectRatioSizing
-
getRendererToAspectRatioX
public float getRendererToAspectRatioX()- Returns:
- the ratio of
canvasWidthtoAspectRatioSizing.width()
-
getRendererToAspectRatioY
public float getRendererToAspectRatioY()- Returns:
- the ratio of
canvasHeighttoAspectRatioSizing.height()
-
resize
public void resize(int screenWidth, int screenHeight) Recalculates theAspectRatioSizingusing the currentAspectModeand the new screen width and height.- Parameters:
screenWidth- the width of the screenscreenHeight- the height of the screen
-