java.lang.Object
technology.sola.engine.graphics.Canvas
- Direct Known Subclasses:
SoftwareRenderer
,SolaImage
Canvas is an array of pixels with a width and height defined.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
width
protected int widthThe width of the canvas. -
height
protected int heightThe height of the canvas. -
pixels
protected int[] pixelsThe pixel array for the canvas.
-
-
Constructor Details
-
Canvas
public Canvas(int width, int height) Creates a Canvas instance with an empty array of pixels.- Parameters:
width
- the width of the Canvasheight
- the height of the canvas
-
Canvas
public Canvas(int width, int height, int[] pixels) Creates a canvas instance with desired array of pixels.- Parameters:
width
- the width of the Canvasheight
- the height of the canvaspixels
- the array of pixels to use for this canvas
-
-
Method Details
-
getPixel
public int getPixel(int x, int y) Returns the hex value of the pixel at desired coordinate on the canvas.- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- the hex value of the pixel
-
getPixel
public int getPixel(float x, float y) Returns the hex value of the pixel at desired coordinate on the canvas. Since pixels coordinates are integers this rounds the float values half up.- Parameters:
x
- the x coordinatey
- the y coordinate- Returns:
- the hex value of the pixel
-
getPixels
public int[] getPixels()- Returns:
- the array of pixels in the canvas
-
getWidth
public int getWidth()- Returns:
- the width of the canvas
-
getHeight
public int getHeight()- Returns:
- the height of the canvas
-