メイン・コンテンツまでスキップ

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, setLinearGradient, or setRadialGradient.

Inherited by: CWRVectorRenderer

Public Types

enumDrawMode { STROKE, FILL_EVEN_ODD, FILL_NON_ZERO }
A list of vector graphics drawing modes.

Public Functions

virtual voiddrawPath(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 voidsetAlpha(uint8_t a) =0
Set the alpha value (opacity) used for future drawings.
virtual voidsetColor(colortype c) =0
Set a constant color used for future drawings.
virtual voidsetLinearGradient(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 voidsetMode(DrawMode mode) =0
Set the drawing mode for the VectorRenderer.
virtual voidsetStrokeLineCap(VGStrokeLineCap lineCap) =0
Sets stroke line cap type.
virtual voidsetStrokeLineJoin(VGStrokeLineJoin lineJoin) =0
Sets stroke line join type.
virtual voidsetStrokeMiterLimit(float miterLimit) =0
Sets stroke miter limit.
virtual voidsetStrokeWidth(float w) =0
Set the width used for future drawings using the VECTOR_STROKE drawing mode.
virtual voidsetTransformationMatrix(const Matrix3x3 & m) =0
Sets the transformation matrix used for future drawings.
virtual voidsetup(const Widget & renderer, const Rect & drawingArea) =0
Start a new drawing in the given area.
virtual voidtearDown() =0
Finalizes the current drawing.
virtual ~VectorRenderer()
Virtual destructor.
VectorRenderer *getInstance()
Gets the VectorRenderer instance.

Public Types Documentation

DrawMode

A list of vector graphics drawing modes.

STROKEDraw the outline of the paths.
FILL_EVEN_ODDFill the paths using the even-odd filling rule.
FILL_NON_ZEROFill the paths using the non-zero filling rule.

Public Functions Documentation

drawPath

virtual void drawPath(const uint8_t *cmds ,=0
uint32_tnCmds ,=0
const float *points ,=0
uint32_tnPoints ,=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.

Parameters:
cmdsAn uint8_t array of VectorPrimitives values
nCmdsThe number of commands in cmds
pointsAn array of coordinates for the commands
nPointsThe number of values in the points arrays
bboxArray 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_ta)

Set the alpha value (opacity) used for future drawings.

The alpha is specified in the interval [0;1].

Parameters:
aThe alpha value.

Reimplemented by: touchgfx::CWRVectorRenderer::setAlpha

setColor

virtual void setColor(colortypec)

Set a constant color used for future drawings.

Parameters:
cAn ARGB color value

Reimplemented by: touchgfx::CWRVectorRenderer::setColor

setLinearGradient

virtual void setLinearGradient(floatx0 ,=0
floaty0 ,=0
floatx1 ,=0
floaty1 ,=0
uint32_tstops ,=0
const float *stopPositions ,=0
const uint32_t *stopColors ,=0
floatwidth ,=0
floatheight ,=0
boolsolid ,=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].

Parameters:
x0X-coordinate for gradient starting point
y0Y-coordinate for gradient starting point
x1X-coordinate for gradient end point
y1Y-coordinate for gradient end point
stopsNumber of stops
stopPositionsPositions of the stops on the line
stopColorsColors of the stops
widthWidth of the box to fill
heightHeight of the box to fill
solidTrue if all colors in the gradient are solid
paletteThe gradient palette

Reimplemented by: touchgfx::CWRVectorRenderer::setLinearGradient

setMode

virtual void setMode(DrawModemode)

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.

Parameters:
modeThe filling mode.

Reimplemented by: touchgfx::CWRVectorRenderer::setMode

setStrokeLineCap

virtual void setStrokeLineCap(VGStrokeLineCaplineCap)

Sets stroke line cap type.

Parameters:
lineCapThe line cap type.

Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeLineCap

setStrokeLineJoin

virtual void setStrokeLineJoin(VGStrokeLineJoinlineJoin)

Sets stroke line join type.

Parameters:
lineJoinThe line join type.

Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeLineJoin

setStrokeMiterLimit

virtual void setStrokeMiterLimit(floatmiterLimit)

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.

Parameters:
miterLimitThe miter limit.

Reimplemented by: touchgfx::CWRVectorRenderer::setStrokeMiterLimit

setStrokeWidth

virtual void setStrokeWidth(floatw)

Set the width used for future drawings using the VECTOR_STROKE drawing mode.

Parameters:
wThe 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.

Parameters:
mThe transformation matrix

Reimplemented by: touchgfx::CWRVectorRenderer::setTransformationMatrix

setup

virtual void setup(const Widget &renderer ,=0
const Rect &drawingArea=0
)=0

Start a new drawing in the given area.

The area typically corresponds to an invalidated area of a Widget. Implementations may lock the framebuffer here.

Parameters:
rendererThe Widget that does the rendering.
drawingAreaThe area of the screen to draw in.

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()

Gets the VectorRenderer instance.

Returns:

The VectorRenderer instance.