VectorRenderer
touchgfx/hal/VectorRenderer.hpp
Abstract interface for classes implementing general 2D vector drawing. Users of this interface are Widgets drawing vector graphics like SVG images.
Implementations draw the path given (in drawPath) using the last color or gradient supplied with setColor or setLinearGradient.
Inherited by: CWRVectorRenderer
Public Types
enum | DrawMode { STROKE, FILL_EVEN_ODD, FILL_NON_ZERO } |
A list of vector graphics drawing modes. | |
Public Functions
virtual void | drawPath(const uint8_t cmds, uint32_t nCmds, const float points, uint32_t nPoints, const float * bbox =0) =0 |
Draw a Path defined by the given array of primitives (commands) and an array of the corresponding floating point coordinates. | |
virtual void | setAlpha(uint8_t a) =0 |
Set the alpha value (opacity) used for future drawings. | |
virtual void | setColor(colortype c) =0 |
Set a constant color used for future drawings. | |
virtual void | setLinearGradient(float x0, float y0, float x1, float y1, uint32_t stops, const float stopPositions, const uint32_t stopColors, float width, float height, bool solid, const uint32_t * palette) =0 |
Set a linear gradient used for future drawings. | |
virtual void | setMode(DrawMode mode) =0 |
Set the drawing mode for the VectorRenderer. | |
virtual void | setStrokeLineCap(VGStrokeLineCap lineCap) =0 |
Sets stroke line cap type. | |
virtual void | setStrokeLineJoin(VGStrokeLineJoin lineJoin) =0 |
Sets stroke line join type. | |
virtual void | setStrokeMiterLimit(float miterLimit) =0 |
Sets stroke miter limit. | |
virtual void | setStrokeWidth(float w) =0 |
Set the width used for future drawings using the VECTOR_STROKE drawing mode. | |
virtual void | setTransformationMatrix(const Matrix3x3 & m) =0 |
Sets the transformation matrix used for future drawings. | |
virtual void | setup(const Rect & canvasAreaAbs, const Rect & invalidatedAreaRel) =0 |
Start a new drawing (invalidated area) within the given canvas area. | |
virtual void | tearDown() =0 |
Finalizes the current drawing. | |
virtual | ~VectorRenderer() |
Virtual destructor. | |
VectorRenderer * | getInstance() |
Gets the VectorRenderer instance. | |
Public Types Documentation
DrawMode
enum DrawMode
A list of vector graphics drawing modes.
STROKE | Draw the outline of the paths. |
FILL_EVEN_ODD | Fill the paths using the even-odd filling rule. |
FILL_NON_ZERO | Fill the paths using the non-zero filling rule. |
Public Functions Documentation
drawPath
virtual void drawPath | ( | const uint8_t * | cmds , | =0 | |
uint32_t | nCmds , | =0 | |||
const float * | points , | =0 | |||
uint32_t | nPoints , | =0 | |||
const float * | bbox =0 | =0 | |||
) | =0 |
Draw a Path defined by the given array of primitives (commands) and an array of the corresponding floating point coordinates.
cmds | An uint8_t array of VectorPrimitives values |
nCmds | The number of commands in cmds |
points | An array of coordinates for the commands |
nPoints | The number of values in the points arrays |
bbox | Array describing the bounding box of the path [minx,miny,maxx,maxy] or 0 if unknown |
Reimplemented by: touchgfx::CWRVectorRenderer::drawPath
setAlpha
virtual void setAlpha | ( | uint8_t | a | ) | |
Set the alpha value (opacity) used for future drawings.
The alpha is specified in the interval [0;1].
a | The alpha value. |
Reimplemented by: touchgfx::CWRVectorRenderer::setAlpha
setColor
Set a constant color used for future drawings.
c | An ARGB color value |
Reimplemented by: touchgfx::CWRVectorRenderer::setColor
setLinearGradient
virtual void setLinearGradient | ( | float | x0 , | =0 | |
float | y0 , | =0 | |||
float | x1 , | =0 | |||
float | y1 , | =0 | |||
uint32_t | stops , | =0 | |||
const float * | stopPositions , | =0 | |||
const uint32_t * | stopColors , | =0 | |||
float | width , | =0 | |||
float | height , | =0 | |||
bool | solid , | =0 | |||
const uint32_t * | palette | =0 | |||
) | =0 |
Set a linear gradient used for future drawings.
The linear gradient is transformed using the current transformation matrix. Multiple colors (stops) can be specified for the gradient. The stop positions are given in the range [0;1].
x0 | X-coordinate for gradient starting point |
y0 | Y-coordinate for gradient starting point |
x1 | X-coordinate for gradient end point |
y1 | Y-coordinate for gradient end point |
stops | Number of stops |
stopPositions | Positions of the stops on the line |
stopColors | Colors of the stops |
width | Width of the box to fill |
height | Height of the box to fill |
solid | True if all colors in the gradient are solid |
palette | The gradient palette |
Reimplemented by: touchgfx::CWRVectorRenderer::setLinearGradient
setMode
Set the drawing mode for the VectorRenderer.
The mode will be used for all subsequent drawings until setMode is called again.
The default mode is non-zero filling.
mode | The filling mode. |
Reimplemented by: touchgfx::CWRVectorRenderer::setMode
setStrokeLineCap
virtual void setStrokeLineCap | ( | VGStrokeLineCap | lineCap | ) | |
Sets stroke line cap type.
lineCap | The line cap type. |
Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeLineCap
setStrokeLineJoin
virtual void setStrokeLineJoin | ( | VGStrokeLineJoin | lineJoin | ) | |
Sets stroke line join type.
lineJoin | The line join type. |
Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeLineJoin
setStrokeMiterLimit
virtual void setStrokeMiterLimit | ( | float | miterLimit | ) | |
Sets stroke miter limit.
This the max distance from the Miter point on the stroke to the stroke point that will be used. If the miter limit is exceeded for a stroke join, it will not be drawn as a Miter but as a Bevel.
miterLimit | The miter limit. |
Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeMiterLimit
setStrokeWidth
virtual void setStrokeWidth | ( | float | w | ) | |
Set the width used for future drawings using the VECTOR_STROKE drawing mode.
w | The width used for stroke drawing. |
Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeWidth
setTransformationMatrix
virtual void setTransformationMatrix | ( | const Matrix3x3 & | m | ) | |
Sets the transformation matrix used for future drawings.
The transformation is reset when setup is called.
m | The transformation matrix |
Reimplemented by: touchgfx::CWRVectorRenderer::setTransformationMatrix
setup
Start a new drawing (invalidated area) within the given canvas area.
The canvas area typically corresponds to the area of a Widget and is given in absolute coordinates, whereas the invalidated area is given in relative coordinates. Implementations may lock the framebuffer here.
canvasAreaAbs | The canvas dimensions in absolute coordinates. |
invalidatedAreaRel | The area which should be updated in relative coordinates to the canvas area. |
Reimplemented by: touchgfx::CWRVectorRenderer::setup
tearDown
virtual void tearDown | ( | ) | =0 |
Finalizes the current drawing.
The implementation may block here until the drawing is done.
The implementation is required to unlock the framebuffer when tearDown is called.
Reimplemented by: touchgfx::CWRVectorRenderer::tearDown
~VectorRenderer
virtual ~VectorRenderer | ( | ) |
Virtual destructor.
getInstance
static VectorRenderer * getInstance | ( | ) |