lv_canvas.h
Defines
-
LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h)
-
LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h)
-
LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h)
-
LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h)
-
LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h)
-
LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h)
-
LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h)
-
LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h)
-
LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h)
-
LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h)
-
LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h)
Functions
-
lv_obj_t *lv_canvas_create(lv_obj_t *parent)
Create a canvas object
- Parameters:
parent -- pointer to an object, it will be the parent of the new canvas
- Returns:
pointer to the created canvas
-
void lv_canvas_set_buffer(lv_obj_t *canvas, void *buf, lv_coord_t w, lv_coord_t h, lv_color_format_t cf)
Set a buffer for the canvas.
- Parameters:
buf -- a buffer where the content of the canvas will be. The required size is (lv_img_color_format_get_px_size(cf) * w) / 8 * h) It can be allocated with
lv_malloc()
or it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or it can be an address in RAM or external SRAMcanvas -- pointer to a canvas object
w -- width of the canvas
h -- height of the canvas
cf -- color format.
LV_IMG_CF_...
-
void lv_canvas_set_px(lv_obj_t *obj, lv_coord_t x, lv_coord_t y, lv_color_t color, lv_opa_t opa)
-
void lv_canvas_set_palette(lv_obj_t *canvas, uint8_t id, lv_color32_t c)
Set the palette color of a canvas with index format. Valid only for
LV_IMG_CF_INDEXED1/2/4/8
- Parameters:
canvas -- pointer to canvas object
id -- the palette color to set:
for
LV_IMG_CF_INDEXED1
: 0..1for
LV_IMG_CF_INDEXED2
: 0..3for
LV_IMG_CF_INDEXED4
: 0..15for
LV_IMG_CF_INDEXED8
: 0..255
c -- the color to set
-
void lv_canvas_get_px(lv_obj_t *obj, lv_coord_t x, lv_coord_t y, lv_color_t *color, lv_opa_t *opa)
-
lv_img_dsc_t *lv_canvas_get_img(lv_obj_t *canvas)
Get the image of the canvas as a pointer to an
lv_img_dsc_t
variable.- Parameters:
canvas -- pointer to a canvas object
- Returns:
pointer to the image descriptor.
-
void lv_canvas_copy_buf(lv_obj_t *canvas, const void *to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h)
Copy a buffer to the canvas
- Parameters:
canvas -- pointer to a canvas object
to_copy -- buffer to copy. The color format has to match with the canvas's buffer color format
x -- left side of the destination position
y -- top side of the destination position
w -- width of the buffer to copy
h -- height of the buffer to copy
-
void lv_canvas_transform(lv_obj_t *canvas, lv_img_dsc_t *img, int16_t angle, uint16_t zoom, lv_coord_t offset_x, lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y, bool antialias)
Transform and image and store the result on a canvas.
- Parameters:
canvas -- pointer to a canvas object to store the result of the transformation.
img -- pointer to an image descriptor to transform. Can be the image descriptor of an other canvas too (
lv_canvas_get_img()
).angle -- the angle of rotation (0..3600), 0.1 deg resolution
zoom -- zoom factor (256 no zoom);
offset_x -- offset X to tell where to put the result data on destination canvas
offset_y -- offset X to tell where to put the result data on destination canvas
pivot_x -- pivot X of rotation. Relative to the source canvas Set to
source width / 2
to rotate around the centerpivot_y -- pivot Y of rotation. Relative to the source canvas Set to
source height / 2
to rotate around the centerantialias -- apply anti-aliasing during the transformation. Looks better but slower.
-
void lv_canvas_blur_hor(lv_obj_t *canvas, const lv_area_t *area, uint16_t r)
Apply horizontal blur on the canvas
- Parameters:
canvas -- pointer to a canvas object
area -- the area to blur. If
NULL
the whole canvas will be blurred.r -- radius of the blur
-
void lv_canvas_blur_ver(lv_obj_t *canvas, const lv_area_t *area, uint16_t r)
Apply vertical blur on the canvas
- Parameters:
canvas -- pointer to a canvas object
area -- the area to blur. If
NULL
the whole canvas will be blurred.r -- radius of the blur
-
void lv_canvas_fill_bg(lv_obj_t *canvas, lv_color_t color, lv_opa_t opa)
Fill the canvas with color
- Parameters:
canvas -- pointer to a canvas
color -- the background color
opa -- the desired opacity
-
void lv_canvas_draw_rect(lv_obj_t *canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, const lv_draw_rect_dsc_t *draw_dsc)
Draw a rectangle on the canvas
- Parameters:
canvas -- pointer to a canvas object
x -- left coordinate of the rectangle
y -- top coordinate of the rectangle
w -- width of the rectangle
h -- height of the rectangle
draw_dsc -- descriptor of the rectangle
-
void lv_canvas_draw_text(lv_obj_t *canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, lv_draw_label_dsc_t *draw_dsc, const char *txt)
Draw a text on the canvas.
- Parameters:
canvas -- pointer to a canvas object
x -- left coordinate of the text
y -- top coordinate of the text
max_w -- max width of the text. The text will be wrapped to fit into this size
draw_dsc -- pointer to a valid label descriptor
lv_draw_label_dsc_t
txt -- text to display
-
void lv_canvas_draw_img(lv_obj_t *canvas, lv_coord_t x, lv_coord_t y, const void *src, const lv_draw_img_dsc_t *draw_dsc)
Draw an image on the canvas
- Parameters:
canvas -- pointer to a canvas object
x -- left coordinate of the image
y -- top coordinate of the image
src -- image source. Can be a pointer an
lv_img_dsc_t
variable or a path an image.draw_dsc -- pointer to a valid label descriptor
lv_draw_img_dsc_t
-
void lv_canvas_draw_line(lv_obj_t *canvas, const lv_point_t points[], uint32_t point_cnt, const lv_draw_line_dsc_t *draw_dsc)
Draw a line on the canvas
- Parameters:
canvas -- pointer to a canvas object
points -- point of the line
point_cnt -- number of points
draw_dsc -- pointer to an initialized
lv_draw_line_dsc_t
variable
-
void lv_canvas_draw_polygon(lv_obj_t *canvas, const lv_point_t points[], uint32_t point_cnt, const lv_draw_rect_dsc_t *draw_dsc)
Draw a polygon on the canvas
- Parameters:
canvas -- pointer to a canvas object
points -- point of the polygon
point_cnt -- number of points
draw_dsc -- pointer to an initialized
lv_draw_rect_dsc_t
variable
-
void lv_canvas_draw_arc(lv_obj_t *canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, int32_t end_angle, const lv_draw_arc_dsc_t *draw_dsc)
Draw an arc on the canvas
- Parameters:
canvas -- pointer to a canvas object
x -- origo x of the arc
y -- origo y of the arc
r -- radius of the arc
start_angle -- start angle in degrees
end_angle -- end angle in degrees
draw_dsc -- pointer to an initialized
lv_draw_line_dsc_t
variable
Variables
-
const lv_obj_class_t lv_canvas_class
-
struct lv_canvas_t