Module technology.sola.engine
Class SoftwareRenderer
java.lang.Object
technology.sola.engine.graphics.Canvas
technology.sola.engine.graphics.renderer.SoftwareRenderer
- All Implemented Interfaces:
Renderer
SoftwareRenderer is a
Renderer
implementation that draws on an in memory array of pixels using the CPU. This
is portable across SolaPlatform
s but will be less performant than a GPU based
implementation.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSoftwareRenderer
(int width, int height) Creates a SoftwareRenderer with width and height. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets all pixels to desiredColor
.createRendererForImage
(SolaImage solaImage) Creates a new Renderer instance that draws to aSolaImage
instead of the screen.void
drawCircle
(float x, float y, float radius, Color color) Draws an unfilled circle.void
Draws aSolaImage
at desired coordinate.void
Draws aSolaImage
scaled to fit within a rectangle specified by x,y, width and height.void
drawImage
(SolaImage solaImage, AffineTransform affineTransform) Draws aSolaImage
withAffineTransform
applied.void
Draws a line.void
Draws an unfilled rectangle.void
fillCircle
(float x, float y, float radius, Color color) Draws a filled circle.void
Draws a filled rectangle.void
fillTriangle
(float x1, float y1, float x2, float y2, float x3, float y3, Color color) Draws a filled triangle.getFont()
void
setBlendFunction
(BlendFunction blendFunction) Sets theBlendFunction
that should be used.void
setClamp
(int x, int y, int width, int height) Restricts rendering of pixels within a rectangle.void
Sets theFont
to use when drawing text.void
Sets theColor
of a pixel at coordinate.Methods inherited from class technology.sola.engine.graphics.Canvas
getHeight, getPixel, getPixel, getPixels, getWidth
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface technology.sola.engine.graphics.renderer.Renderer
clear, createLayers, drawString, drawString, drawToLayer, drawToLayer, drawTriangle, getHeight, getLayer, getWidth, resetClamp, setPixel
-
Constructor Details
-
SoftwareRenderer
public SoftwareRenderer(int width, int height) Creates a SoftwareRenderer with width and height.- Parameters:
width
- width of the rendererheight
- height of the renderer
-
-
Method Details
-
setBlendFunction
Description copied from interface:Renderer
Sets theBlendFunction
that should be used.- Specified by:
setBlendFunction
in interfaceRenderer
- Parameters:
blendFunction
- the newBlendMode
to use
-
getBlendFunction
- Specified by:
getBlendFunction
in interfaceRenderer
- Returns:
- the current
BlendFunction
being used when drawing
-
createRendererForImage
Description copied from interface:Renderer
Creates a new Renderer instance that draws to aSolaImage
instead of the screen.- Specified by:
createRendererForImage
in interfaceRenderer
- Parameters:
solaImage
- the image to draw to- Returns:
- a new renderer instance drawing to an image
-
getFont
-
setFont
Description copied from interface:Renderer
Sets theFont
to use when drawing text. -
setClamp
public void setClamp(int x, int y, int width, int height) Description copied from interface:Renderer
Restricts rendering of pixels within a rectangle. Any setPixel call outside of this rectangle will be ignored. -
clear
Description copied from interface:Renderer
Sets all pixels to desiredColor
. -
setPixel
Description copied from interface:Renderer
Sets theColor
of a pixel at coordinate. -
drawLine
Description copied from interface:Renderer
Draws a line. -
drawRect
Description copied from interface:Renderer
Draws an unfilled rectangle. -
fillRect
Description copied from interface:Renderer
Draws a filled rectangle. -
drawCircle
Description copied from interface:Renderer
Draws an unfilled circle. Uses Bresenham's circle drawing algorithm.- Specified by:
drawCircle
in interfaceRenderer
- Parameters:
x
- top left coordinate xy
- top left coordinate yradius
- radius of the circlecolor
-Color
of the circle
-
fillCircle
Description copied from interface:Renderer
Draws a filled circle.- Specified by:
fillCircle
in interfaceRenderer
- Parameters:
x
- top left coordinate xy
- top left coordinate yradius
- radius of the circlecolor
-Color
of the circle
-
fillTriangle
Description copied from interface:Renderer
Draws a filled triangle.- Specified by:
fillTriangle
in interfaceRenderer
- Parameters:
x1
- x coordinate for the first pointy1
- y coordinate for the first pointx2
- x coordinate for the second pointy2
- y coordinate for the second pointx3
- x coordinate for the third pointy3
- y coordinate for the third pointcolor
-Color
of the triangle
-
drawImage
Description copied from interface:Renderer
Draws aSolaImage
at desired coordinate. The coordinate will be the top-left of the image drawn. -
drawImage
Description copied from interface:Renderer
Draws aSolaImage
withAffineTransform
applied. -
drawImage
Description copied from interface:Renderer
Draws aSolaImage
scaled to fit within a rectangle specified by x,y, width and height. -
getLayers
-