Skip to main content
Version: 4.16

PainterGRAY4

The PainterGRAY4 class allows a shape to be filled with a given color and alpha value. This allows transparent, anti-aliased elements to be drawn.

See: AbstractPainter

Inherits from: AbstractPainterGRAY4, AbstractPainter

Public Functions#

colortypegetColor() const
Gets the current color.
PainterGRAY4(colortype color =0, uint8_t alpha =255)
Initializes a new instance of the PainterGRAY4 class.
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.
voidsetColor(colortype color)
Sets color and alpha to use when drawing the CanvasWidget.

Protected Functions#

virtual boolrenderNext(uint8_t & gray, uint8_t & alpha)
Get the color of the next pixel in the scan line to blend into the framebuffer.

Protected Attributes#

uint8_tpainterGray
The gray color.

Additional inherited members#

Public Functions inherited from AbstractPainterGRAY4#

Protected Functions inherited from AbstractPainterGRAY4#

virtual boolrenderInit()
Initialize rendering of a single scan line of pixels for the render.
virtual voidrenderPixel(uint8_t * p, uint16_t offset, uint8_t gray)
Renders (writes) the specified color into the framebuffer.

Protected Attributes inherited from AbstractPainterGRAY4#

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

Public Functions inherited from AbstractPainter#

AbstractPainter()
Initializes a new instance of the AbstractPainter class.
virtual uint8_tgetAlpha() const
Gets the current alpha value of the widget.
virtual voidsetAlpha(uint8_t newAlpha)
Sets the opacity (alpha value).
voidsetOffset(uint16_t offsetX, uint16_t offsetY)
Sets the offset of the area being drawn.
virtual ~AbstractPainter()
Finalizes an instance of the AbstractPainter class.

Protected Functions inherited from AbstractPainter#

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_tpainterAlpha
The alpha value for the painter.
uint8_twidgetAlpha
The alpha of the widget using the painter.

Public Functions Documentation#

getColor#

colortype getColor()const

Gets the current color.

Returns:

The color.

PainterGRAY4#

PainterGRAY4(colortypecolor =0,
uint8_talpha =255
)

Initializes a new instance of the PainterGRAY4 class.

Parameters:
color(Optional) the color, default is black.
alpha(Optional) the alpha, default is 255 i.e. solid.

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::AbstractPainterGRAY4::render

setColor#

void setColor(colortypecolor)

Sets color and alpha to use when drawing the CanvasWidget.

Parameters:
colorThe color.

Protected Functions Documentation#

renderNext#

virtual bool renderNext(uint8_t &gray ,
uint8_t &alpha
)

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

Parameters:
grayThe gray color (0-15).
alphaThe alpha.
Returns:

true if the pixel should be painted, false otherwise.

Reimplements: touchgfx::AbstractPainterGRAY4::renderNext

Protected Attributes Documentation#

painterGray#

uint8_t painterGray

The gray color.