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 SolaPlatforms 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 TypeMethodDescriptionvoidSets all pixels to desiredColor.createRendererForImage(SolaImage solaImage) Creates a new Renderer instance that draws to aSolaImageinstead of the screen.voiddrawCircle(float x, float y, float radius, Color color) Draws an unfilled circle.voidDraws aSolaImageat desired coordinate.voidDraws aSolaImagescaled to fit within a rectangle specified by x,y, width and height.voiddrawImage(SolaImage solaImage, AffineTransform affineTransform) Draws aSolaImagewithAffineTransformapplied.voidDraws a line.voidDraws an unfilled rectangle.voidfillCircle(float x, float y, float radius, Color color) Draws a filled circle.voidfillPolygon(Vector2D[] points, Color color) Draws a filled polygon.voidDraws a filled rectangle.voidfillTriangle(float x1, float y1, float x2, float y2, float x3, float y3, Color color) Draws a filled triangle.getFont()voidsetBlendFunction(BlendFunction blendFunction) Sets theBlendFunctionthat should be used.voidsetClamp(int x, int y, int width, int height) Restricts rendering of pixels within a rectangle.voidSets theFontto use when drawing text.voidSets theColorof a pixel at coordinate.Methods inherited from class technology.sola.engine.graphics.Canvas
getHeight, getPixel, getPixel, getPixels, getWidthMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface technology.sola.engine.graphics.renderer.Renderer
clear, createLayers, drawPolygon, 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:RendererSets theBlendFunctionthat should be used.- Specified by:
setBlendFunctionin interfaceRenderer- Parameters:
blendFunction- the newBlendModeto use
-
getBlendFunction
- Specified by:
getBlendFunctionin interfaceRenderer- Returns:
- the current
BlendFunctionbeing used when drawing
-
createRendererForImage
Description copied from interface:RendererCreates a new Renderer instance that draws to aSolaImageinstead of the screen.- Specified by:
createRendererForImagein interfaceRenderer- Parameters:
solaImage- the image to draw to- Returns:
- a new renderer instance drawing to an image
-
getFont
-
setFont
Description copied from interface:RendererSets theFontto use when drawing text. -
setClamp
public void setClamp(int x, int y, int width, int height) Description copied from interface:RendererRestricts rendering of pixels within a rectangle. Any setPixel call outside of this rectangle will be ignored. -
clear
Description copied from interface:RendererSets all pixels to desiredColor. -
setPixel
Description copied from interface:RendererSets theColorof a pixel at coordinate. -
drawLine
Description copied from interface:RendererDraws a line. -
drawRect
Description copied from interface:RendererDraws an unfilled rectangle. -
fillRect
Description copied from interface:RendererDraws a filled rectangle. -
drawCircle
Description copied from interface:RendererDraws an unfilled circle. Uses Bresenham's circle drawing algorithm.- Specified by:
drawCirclein interfaceRenderer- Parameters:
x- top left coordinate xy- top left coordinate yradius- radius of the circlecolor-Colorof the circle
-
fillCircle
Description copied from interface:RendererDraws a filled circle.- Specified by:
fillCirclein interfaceRenderer- Parameters:
x- top left coordinate xy- top left coordinate yradius- radius of the circlecolor-Colorof the circle
-
fillTriangle
Description copied from interface:RendererDraws a filled triangle.- Specified by:
fillTrianglein 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-Colorof the triangle
-
fillPolygon
Description copied from interface:RendererDraws a filled polygon.- Specified by:
fillPolygonin interfaceRenderer- Parameters:
points- the points of the polygoncolor- theColorof the polygon
-
drawImage
Description copied from interface:RendererDraws aSolaImageat desired coordinate. The coordinate will be the top-left of the image drawn. -
drawImage
Description copied from interface:RendererDraws aSolaImagewithAffineTransformapplied. -
drawImage
Description copied from interface:RendererDraws aSolaImagescaled to fit within a rectangle specified by x,y, width and height. -
getLayers
-