跳轉到主要內容

AbstractPainterARGB2222

The AbstractPainterARGB2222 class is an abstract class for creating a painter to draw on a ARGB2222 display using CanvasWidgetRenderer.

See: AbstractPainter

Inherits from: AbstractPainter

Inherited by: PainterARGB2222, PainterARGB2222Bitmap

Public Functions

AbstractPainterARGB2222()
FORCE_INLINE_FUNCTION uint8_tmixColors(uint8_t newpix, uint8_t bufpix, uint8_t alpha)
Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel, and the inverse alpha applied to the buffer pixel.
FORCE_INLINE_FUNCTION uint8_tmixColors(uint8_t R, uint8_t G, uint8_t B, uint8_t bufpix, uint8_t alpha)
Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel, and the inverse alpha applied to the buffer pixel.
virtual voidrender(uint8_t ptr, int x, int xAdjust, int y, unsigned count, const uint8_t covers)
Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers.

Protected Functions

virtual boolrenderInit()
Initialize rendering of a single scan line of pixels for the render.
virtual boolrenderNext(uint8_t & red, uint8_t & green, uint8_t & blue, uint8_t & alpha)
Get the color of the next pixel in the scan line to blend into the framebuffer.
virtual voidrenderPixel(uint8_t * p, uint8_t red, uint8_t green, uint8_t blue)
Renders (writes) the specified color into the framebuffer.

Protected Attributes

intcurrentX
Current x coordinate relative to the widget.
intcurrentY
Current y coordinate relative to the widget.

Additional inherited members

Public Functions inherited from AbstractPainter

AbstractPainter()
Initializes a new instance of the AbstractPainter class.
virtual ~AbstractPainter()
Finalizes an instance of the AbstractPainter class.

Protected Functions inherited from AbstractPainter

voidsetAreaOffset(uint16_t offsetX, uint16_t offsetY)
Sets the offset of the area being drawn.
voidsetWidgetAlpha(const uint8_t alpha)
Sets the widget alpha to allow an entire canvas widget to easily be faded without changing the painter of the widget.
FORCE_INLINE_FUNCTION boolcompatibleFramebuffer(Bitmap::BitmapFormat format)
Helper function to check if the provided bitmap format matches the current framebuffer format.

Protected Attributes inherited from AbstractPainter

int16_tareaOffsetX
The offset x coordinate of the area being drawn.
int16_tareaOffsetY
The offset y coordinate of the area being drawn.
uint8_twidgetAlpha
The alpha of the widget using the painter.

Public Functions Documentation

AbstractPainterARGB2222

mixColors

FORCE_INLINE_FUNCTION uint8_t mixColors(uint8_tnewpix ,
uint8_tbufpix ,
uint8_talpha
)

Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel, and the inverse alpha applied to the buffer pixel.

Parameters:
newpixThe new pixel value.
bufpixThe buffer pixel value.
alphaThe alpha to apply to the new pixel.
Returns:

The result of blending the two colors into a new color.

mixColors

FORCE_INLINE_FUNCTION uint8_t mixColors(uint8_tR ,
uint8_tG ,
uint8_tB ,
uint8_tbufpix ,
uint8_talpha
)

Mix colors from a new pixel and a buffer pixel with the given alpha applied to the new pixel, and the inverse alpha applied to the buffer pixel.

Parameters:
RThe red color.
GThe green color.
BThe blue color.
bufpixThe buffer pixel value.
alphaThe alpha of the R,G,B.
Returns:

The result of blending the two colors into a new color.

render

virtual void render(uint8_t *ptr ,
intx ,
intxAdjust ,
inty ,
unsignedcount ,
const uint8_t *covers
)

Paint a designated part of the RenderingBuffer with respect to the amount of coverage of each pixel given by the parameter covers.

The cover is the alpha for each pixel, which is what makes it possible to have smooth anti-aliased edges on the shapes drawn with CanvasWidgetRenderer.

Parameters:
ptrPointer to the row in the RenderingBuffer.
xThe x coordinate.
xAdjustThe minor adjustment of x (used when a pixel is smaller than a byte to specify that the ptr should have been advanced "xAdjust" pixels futher into the byte).
yThe y coordinate.
countNumber of pixels to fill.
coversThe coverage in of each pixel.
Note

The implementation of render() in the AbstractPainter classes is a generic (i.e. slow) implementation that should be completely implemented in subclasses of AbstractPainter for better performance.

Reimplements: touchgfx::AbstractPainter::render

Reimplemented by: touchgfx::PainterARGB2222::render, touchgfx::PainterARGB2222Bitmap::render

Protected Functions Documentation

renderInit

virtual bool renderInit()

Initialize rendering of a single scan line of pixels for the render.

If renderInit returns false, the scanline will not be rendered.

Returns:

true if it succeeds, false if it fails.

Reimplemented by: touchgfx::PainterARGB2222Bitmap::renderInit

renderNext

virtual bool renderNext(uint8_t &red ,
uint8_t &green ,
uint8_t &blue ,
uint8_t &alpha
)

Get the color of the next pixel in the scan line to blend into the framebuffer.

Parameters:
redThe red.
greenThe green.
blueThe blue.
alphaThe alpha.
Returns:

true if the pixel should be painted, false otherwise.

Reimplemented by: touchgfx::PainterARGB2222::renderNext

renderPixel

virtual void renderPixel(uint8_t *p ,
uint8_tred ,
uint8_tgreen ,
uint8_tblue
)

Renders (writes) the specified color into the framebuffer.

Parameters:
ppointer into the framebuffer where the given color should be written.
redThe red color.
greenThe green color.
blueThe blue color.

Protected Attributes Documentation

currentX

int currentX

Current x coordinate relative to the widget.

currentY

int currentY

Current y coordinate relative to the widget.