![]() |
BSB Developer Docs
|
A canvas widget for drawing arbitrary graphics. More...
Go to the source code of this file.
Typedefs | |
| typedef struct Canvas | Canvas |
| Canvas opaque structure. | |
Functions | |
| Canvas * | canvas_alloc (Widget *parent, int32_t width, int32_t height) |
| Create a new Canvas instance. | |
| void | canvas_free (Canvas *instance) |
| Delete a Canvas instance. | |
| void | canvas_draw_begin (Canvas *instance) |
| Initialize the drawing process. | |
| void | canvas_draw_end (Canvas *instance) |
| Finalize the drawing process. | |
| Widget * | canvas_get_base (Canvas *instance) |
| Get a pointer to the base class instance. | |
| void | canvas_set_fill_color (Canvas *instance, Color color) |
| Set the color for fill operations. | |
| void | canvas_set_fill_opacity (Canvas *instance, uint8_t opacity) |
| Set the opacity for fill operations. | |
| void | canvas_set_line_color (Canvas *instance, Color color) |
| Set the color for line drawing operations. | |
| void | canvas_set_line_width (Canvas *instance, int32_t width) |
| Set the line width for line drawing operations. | |
| void | canvas_set_line_opacity (Canvas *instance, uint8_t opacity) |
| Set the opacity for line drawing operations. | |
| void | canvas_clear (Canvas *instance) |
| Clear all canvas contents. | |
| void | canvas_fill (Canvas *instance) |
| Fill the canvas with solid color. | |
| void | canvas_draw_pixel (Canvas *instance, int32_t x, int32_t y, Color color) |
| Draw a single pixel with the given coordinates and color. | |
| void | canvas_draw_line (Canvas *instance, int32_t x1, int32_t y1, int32_t x2, int32_t y2) |
| Draw a single segment between two points. | |
| void | canvas_draw_rect (Canvas *instance, int32_t x, int32_t y, int32_t w, int32_t h, bool fill) |
| Draw a rectangle based on its top-left corner and dimensions. | |
| void | canvas_draw_text (Canvas *instance, int32_t x, int32_t y, const char *text) |
| Draw a plain text label. | |
A canvas widget for drawing arbitrary graphics.
Create a new Canvas instance.
| [in,out] | parent | pointer to the parent Widget instance |
| [in] | width | canvas width in pixels |
| [in] | height | canvas height in pixels |
| void canvas_clear | ( | Canvas * | instance | ) |
Clear all canvas contents.
Previously set drawing parameters will remain unchanged.
| [in,out] | instance | pointer to the Canvas instance to be cleared |
| void canvas_draw_begin | ( | Canvas * | instance | ) |
Initialize the drawing process.
This function must be called before any drawing operations.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| void canvas_draw_end | ( | Canvas * | instance | ) |
Finalize the drawing process.
This function must be called after all drawing operations.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| void canvas_draw_line | ( | Canvas * | instance, |
| int32_t | x1, | ||
| int32_t | y1, | ||
| int32_t | x2, | ||
| int32_t | y2 ) |
Draw a single segment between two points.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| [in] | x1 | horizontal (x) coordinate of the starting point |
| [in] | y1 | vertical (y) coordinate of the starting point |
| [in] | x2 | horizontal (x) coordinate of the ending point |
| [in] | y2 | vertical (y) coordinate of the ending point |
Draw a single pixel with the given coordinates and color.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| [in] | x | horizontal (x) coordinate of the pixel |
| [in] | y | vertical (y) coordinate of the pixel |
| [in] | color | color of the pixel |
| void canvas_draw_rect | ( | Canvas * | instance, |
| int32_t | x, | ||
| int32_t | y, | ||
| int32_t | w, | ||
| int32_t | h, | ||
| bool | fill ) |
Draw a rectangle based on its top-left corner and dimensions.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| [in] | x | horizontal (x) coordinate of the corner |
| [in] | y | vertical (y) coordinate of the corner |
| [in] | w | horizontal dimension of the rectangle |
| [in] | h | vertical dimension of the rectangle |
| [in] | fill | if true, fill the rectangle with the fill color, otherwise draw only its border |
| void canvas_draw_text | ( | Canvas * | instance, |
| int32_t | x, | ||
| int32_t | y, | ||
| const char * | text ) |
Draw a plain text label.
| [in,out] | instance | pointer to the Canvas instance to be drawn on |
| [in] | x | horizontal (x) offset of the text |
| [in] | y | vertical (y) offset of the text |
| [in] | text | zero-terminated string containing the text to be shown |
| void canvas_fill | ( | Canvas * | instance | ) |
Fill the canvas with solid color.
| [in,out] | instance | pointer to the Canvas instance to be filled |
| void canvas_free | ( | Canvas * | instance | ) |
Delete a Canvas instance.
| [in,out] | instance | pointer to the Canvas instance to be deleted |
Get a pointer to the base class instance.
The return value can be used in all Widget methods.
| [in,out] | instance | pointer to the Canvas instance to be queried |
Set the color for fill operations.
| [in,out] | instance | pointer to the Canvas instance to be modified |
| [in] | color | Color to be used as fill color |
| void canvas_set_fill_opacity | ( | Canvas * | instance, |
| uint8_t | opacity ) |
Set the opacity for fill operations.
| [in,out] | instance | pointer to the Canvas instance to be modified |
| [in] | opacity | opacity value for fills (0 - transparent, 255 - fully opaque) |
Set the color for line drawing operations.
| [in,out] | instance | pointer to the Canvas instance to be modified |
| [in] | color | Color to be used as line color |
| void canvas_set_line_opacity | ( | Canvas * | instance, |
| uint8_t | opacity ) |
Set the opacity for line drawing operations.
| [in,out] | instance | pointer to the Canvas instance to be modified |
| [in] | opacity | opacity value for lines (0 - transparent, 255 - fully opaque) |
| void canvas_set_line_width | ( | Canvas * | instance, |
| int32_t | width ) |
Set the line width for line drawing operations.
| [in,out] | instance | pointer to the Canvas instance to be modified |
| [in] | width | line width in pixels (0 - no lines) |