@@ -33,10 +33,13 @@ For `LV_IMG_CF_INDEXED_1/2/4/8` color formats a palette needs to be
|
||||
initialized with `lv_canvas_set_palette(canvas, 3, LV_COLOR_RED)`. It sets pixels with *index=3* to red.
|
||||
|
||||
### Drawing
|
||||
To set a pixel on the canvas, use `lv_canvas_set_px(canvas, x, y, LV_COLOR_RED)`.
|
||||
With `LV_IMG_CF_INDEXED_...` or `LV_IMG_CF_ALPHA_...`, the index of the color or the alpha value needs to be passed as color.
|
||||
To set a pixel's color on the canvas, use `lv_canvas_set_px_color(canvas, x, y, LV_COLOR_RED)`.
|
||||
With `LV_IMG_CF_INDEXED_...` the index of the color needs to be passed as color.
|
||||
E.g. `lv_color_t c; c.full = 3;`
|
||||
|
||||
To set a pixel's opacity with `LV_IMG_CF_TRUE_COLOR_ALPHA` or `LV_IMG_CF_ALPHA_...` format on the canvas, use `lv_canvas_set_px_opa(canvas, x, y, opa)`.
|
||||
|
||||
|
||||
`lv_canvas_fill_bg(canvas, LV_COLOR_BLUE, LV_OPA_50)` fills the whole canvas to blue with 50% opacity. Note that if the current color format doesn't support colors (e.g. `LV_IMG_CF_ALPHA_2BIT`) the color will be ignored.
|
||||
Similarly, if opacity is not supported (e.g. `LV_IMG_CF_TRUE_COLOR`) it will be ignored.
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void lv_example_canvas_2(void)
|
||||
uint32_t y;
|
||||
for( y = 10; y < 30; y++) {
|
||||
for( x = 5; x < 20; x++) {
|
||||
lv_canvas_set_px(canvas, x, y, c0);
|
||||
lv_canvas_set_px_color(canvas, x, y, c0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ lv_res_t lv_qrcode_update(lv_obj_t * qrcode, const void * data, uint32_t data_le
|
||||
|
||||
if(aligned == false) {
|
||||
c.full = a ? 0 : 1;
|
||||
lv_canvas_set_px(qrcode, x, y, c);
|
||||
lv_canvas_set_px_color(qrcode, x, y, c);
|
||||
} else {
|
||||
if(!a) b |= (1 << (7 - p));
|
||||
p++;
|
||||
|
||||
@@ -74,7 +74,7 @@ void lv_canvas_set_buffer(lv_obj_t * obj, void * buf, lv_coord_t w, lv_coord_t h
|
||||
lv_img_set_src(obj, &canvas->dsc);
|
||||
}
|
||||
|
||||
void lv_canvas_set_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
void lv_canvas_set_px_color(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
@@ -84,6 +84,16 @@ void lv_canvas_set_px(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_canvas_set_px_opa(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_opa_t opa)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_canvas_t * canvas = (lv_canvas_t *)obj;
|
||||
|
||||
lv_img_buf_set_px_alpha(&canvas->dsc, x, y, opa);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_canvas_set_palette(lv_obj_t * obj, uint8_t id, lv_color_t c)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
@@ -70,9 +70,27 @@ void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_
|
||||
* @param canvas
|
||||
* @param x x coordinate of the point to set
|
||||
* @param y x coordinate of the point to set
|
||||
* @param c color of the point
|
||||
* @param c color of the pixel
|
||||
*/
|
||||
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);
|
||||
void lv_canvas_set_px_color(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);
|
||||
|
||||
/**
|
||||
* DEPRECATED: added only for backward compatibility
|
||||
*/
|
||||
static inline void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
{
|
||||
lv_canvas_set_px_color(canvas, x, y, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the opacity of a pixel on the canvas
|
||||
* @param canvas
|
||||
* @param x x coordinate of the point to set
|
||||
* @param y x coordinate of the point to set
|
||||
* @param opa opacity of the pixel (0..255)
|
||||
*/
|
||||
void lv_canvas_set_px_opa(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
|
||||
|
||||
|
||||
/**
|
||||
* Set the palette color of a canvas with index format. Valid only for `LV_IMG_CF_INDEXED1/2/4/8`
|
||||
|
||||
Reference in New Issue
Block a user