A class that implements basic graphic drawing primitives for widgets. More...
#include <widget_primitives.h>


Public Member Functions | |
| GraphicDrawer (struct_ConfigGraphicWidget graph_cfg, CanvasFormat canvas_format) | |
| Constructor of the GraphicDrawer class. | |
| GraphicDrawer (struct_ConfigTextWidget text_cfg, CanvasFormat canvas_format) | |
| Constructor of the GraphicDrawer class. | |
| GraphicDrawer (struct_ConfigTextWidget text_cfg, CanvasFormat canvas_format, size_t frame_width, size_t frame_height) | |
| Constructor of the GraphicDrawer class. | |
| void | clear_widget () |
| fill the graphic pixel buffer with 0x00. | |
| void | hline (uint8_t x, uint8_t y, size_t w, ColorIndex color=ColorIndex::WHITE) |
| Draw a color horizontal line, starting at frame position (x,y), on w number of pixel. | |
| void | vline (uint8_t x, uint8_t y, size_t h, ColorIndex color=ColorIndex::WHITE) |
| Draw a color vertical line, starting at frame position (x,y), on w number of pixel. | |
| void | line (int x0, int y0, int x1, int y1, ColorIndex color=ColorIndex::WHITE) |
| Draw a color line, starting at frame position (x0,y0), ending at frame position (x1,y1). | |
| void | rect (uint8_t start_x, uint8_t start_y, size_t w, size_t h, bool fill=false, ColorIndex color=ColorIndex::WHITE) |
| Draw a rectangle, starting at frame position (x,y), w wide and h high. | |
| void | circle (int radius, int x_center, int y_center, bool fill=false, ColorIndex color=ColorIndex::WHITE) |
| draw a cercle of size radius, centered at (x_center, y_center) https://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham https://en.wikipedia.org/wiki/Midpoint_circle_algorithm procédure tracerCercle (entier rayon, entier x_centre, entier y_centre) déclarer entier x, y, m ; x ← 0 ; y ← rayon ; // on se place en haut du cercle m ← 5 - 4*rayon ; // initialisation Tant que x <= y // tant qu'on est dans le second octant tracerPixel( x+x_centre, y+y_centre ) ; tracerPixel( y+x_centre, x+y_centre ) ; tracerPixel( -x+x_centre, y+y_centre ) ; tracerPixel( -y+x_centre, x+y_centre ) ; tracerPixel( x+x_centre, -y+y_centre ) ; tracerPixel( y+x_centre, -x+y_centre ) ; tracerPixel( -x+x_centre, -y+y_centre ) ; tracerPixel( -y+x_centre, -x+y_centre ) ; si m > 0 alors //choix du point F y ← y - 1 ; m ← m - 8*y ; fin si ; x ← x + 1 ; m ← m + 8*x + 4 ; fin tant que ; fin de procédure ; | |
| virtual void | draw_border (ColorIndex color=ColorIndex::WHITE) |
| draw a rectangle around the widget. | |
Public Attributes | |
| bool | widget_with_border {false} |
| if true, the widget is surrounded by a one-pixel border | |
| uint8_t | widget_border_width |
| this is the border size of the widget. 0 if no border, 1 if border | |
| Canvas * | canvas |
| the associated canvas in which the widget writes text and draws graphics | |
Protected Attributes | |
| size_t | widget_width {128} |
| As a widget can be surrounded by a border, the actual widget width is not the associated framebuffer width. | |
| size_t | widget_height {8} |
| As a widget can be surrounded by a border, the actual widget height is not the associated framebuffer height. | |
| uint8_t | widget_start_x |
| this is the actual horizontal start of the widget drawing area, taken into account the presence of border. | |
| uint8_t | widget_start_y |
| this is the actual vertical start of the widget drawing area, taken into account the presence of border. | |
A class that implements basic graphic drawing primitives for widgets.
| GraphicDrawer::GraphicDrawer | ( | struct_ConfigGraphicWidget | graph_cfg, |
| CanvasFormat | canvas_format ) |
Constructor of the GraphicDrawer class.
| graph_cfg | the configuration data for the graphical frame |
| canvas_format | the format of the associated canvas (see CanvasFormat) |

| GraphicDrawer::GraphicDrawer | ( | struct_ConfigTextWidget | text_cfg, |
| CanvasFormat | canvas_format ) |
Constructor of the GraphicDrawer class.
| text_cfg | the configuration data for the textual frame |
| canvas_format | the format of the associated canvas (see CanvasFormat) |
| GraphicDrawer::GraphicDrawer | ( | struct_ConfigTextWidget | text_cfg, |
| CanvasFormat | canvas_format, | ||
| size_t | frame_width, | ||
| size_t | frame_height ) |
Constructor of the GraphicDrawer class.
| text_cfg | the configuration data for the textual frame |
| canvas_format | the format of the associated canvas (see CanvasFormat) |
| frame_width | the frame width in pixel |
| frame_height | the frame height in pixel |
| void GraphicDrawer::circle | ( | int | radius, |
| int | x_center, | ||
| int | y_center, | ||
| bool | fill = false, | ||
| ColorIndex | color = ColorIndex::WHITE ) |
draw a cercle of size radius, centered at (x_center, y_center) https://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham https://en.wikipedia.org/wiki/Midpoint_circle_algorithm procédure tracerCercle (entier rayon, entier x_centre, entier y_centre) déclarer entier x, y, m ; x ← 0 ; y ← rayon ; // on se place en haut du cercle m ← 5 - 4*rayon ; // initialisation Tant que x <= y // tant qu'on est dans le second octant tracerPixel( x+x_centre, y+y_centre ) ; tracerPixel( y+x_centre, x+y_centre ) ; tracerPixel( -x+x_centre, y+y_centre ) ; tracerPixel( -y+x_centre, x+y_centre ) ; tracerPixel( x+x_centre, -y+y_centre ) ; tracerPixel( y+x_centre, -x+y_centre ) ; tracerPixel( -x+x_centre, -y+y_centre ) ; tracerPixel( -y+x_centre, -x+y_centre ) ; si m > 0 alors //choix du point F y ← y - 1 ; m ← m - 8*y ; fin si ; x ← x + 1 ; m ← m + 8*x + 4 ; fin tant que ; fin de procédure ;
| radius | radius, in pixel, of the circle |
| x_center | horizontal position of the center of the cercle |
| y_center | vertical position of the center on the cercle |
| fill | if true, the circle is filled with color c |
| color | color of the border of the circle, default to WHITE |

| void GraphicDrawer::clear_widget | ( | ) |
fill the graphic pixel buffer with 0x00.
|
virtual |
draw a rectangle around the widget.
| color | the color of the border |
Reimplemented in TextWriter.

| void GraphicDrawer::hline | ( | uint8_t | x, |
| uint8_t | y, | ||
| size_t | w, | ||
| ColorIndex | color = ColorIndex::WHITE ) |
Draw a color horizontal line, starting at frame position (x,y), on w number of pixel.
| x | horizontal start of line |
| y | vertical start of line |
| w | length of the line in number of pixel |
| color | color of the line, default to WHITE |

| void GraphicDrawer::line | ( | int | x0, |
| int | y0, | ||
| int | x1, | ||
| int | y1, | ||
| ColorIndex | color = ColorIndex::WHITE ) |
Draw a color line, starting at frame position (x0,y0), ending at frame position (x1,y1).
| x0 | horizontal start of line |
| y0 | vertical start of line |
| x1 | horizontal end of line |
| y1 | vertical end of line |
| color | color of the line, default to WHITE |
| void GraphicDrawer::rect | ( | uint8_t | start_x, |
| uint8_t | start_y, | ||
| size_t | w, | ||
| size_t | h, | ||
| bool | fill = false, | ||
| ColorIndex | color = ColorIndex::WHITE ) |
Draw a rectangle, starting at frame position (x,y), w wide and h high.
| start_x | horizontal start of the rectangle |
| start_y | vertical start of the rectangle |
| w | number of pixel of the rectangle width |
| h | number of pixel of the rectangle height |
| fill | if true, the rectangle is filled with color |
| color | color of the border of the rectangle, default to WHITE |


| void GraphicDrawer::vline | ( | uint8_t | x, |
| uint8_t | y, | ||
| size_t | h, | ||
| ColorIndex | color = ColorIndex::WHITE ) |
Draw a color vertical line, starting at frame position (x,y), on w number of pixel.
| x | horizontal start of line |
| y | vertical start of line |
| h | length of the line in number of pixel |
| color | color of the line, default to WHITE |

|
protected |
this is the actual horizontal start of the widget drawing area, taken into account the presence of border.
|
protected |
this is the actual vertical start of the widget drawing area, taken into account the presence of border.