1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

Merge pull request #783 from seyyah/dev-5.3

lv_canvas: lv_canvas_boundary_fill4 function interface enhancement
This commit is contained in:
Gabor Kiss-Vamosi 2019-01-31 15:55:25 +01:00 committed by GitHub
commit 2274ca348b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 20 deletions

View File

@ -327,6 +327,8 @@ void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_c
* @param point1 start point of the line
* @param point2 end point of the line
* @param color color of the line
*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
*/
/*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
@ -344,8 +346,7 @@ void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
int err = (dx>dy ? dx : -dy)/2, e2;
for(;;){
// setPixel(x0,y0);
for(;;){
lv_canvas_set_px(canvas, x0, y0, color);
if (x0==x1 && y0==y1) break;
@ -400,10 +401,10 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param color line color of the polygon
* @param bg_color background color of the polygon
* @param boundary_color line color of the polygon
* @param fill_color fill color of the polygon
*/
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t color, lv_color_t bg_color)
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color)
{
uint32_t x = 0, y = 0;
uint8_t i;
@ -416,8 +417,7 @@ void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
x = x / size;
y = y / size;
// lv_canvas_flood_fill(canvas, (lv_coord_t) x, (lv_coord_t) y, color, bg_color);
lv_canvas_boundary_fill4(canvas, (lv_coord_t) x, (lv_coord_t) y, color, color);
lv_canvas_boundary_fill4(canvas, (lv_coord_t) x, (lv_coord_t) y, boundary_color, fill_color);
}
/**
@ -425,10 +425,10 @@ void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param fill_color fill color of the area
* @param boundary_color edge/boundary color of the area
* @param fill_color fill color of the area
*/
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t boundary_color)
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color)
{
lv_color_t c;
@ -437,13 +437,12 @@ void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_
if(c.full != boundary_color.full &&
c.full != fill_color.full)
{
// putpixel(x, y, fill_color);
lv_canvas_set_px(canvas, x, y, fill_color);
lv_canvas_boundary_fill4(canvas, x + 1, y, fill_color, boundary_color);
lv_canvas_boundary_fill4(canvas, x, y + 1, fill_color, boundary_color);
lv_canvas_boundary_fill4(canvas, x - 1, y, fill_color, boundary_color);
lv_canvas_boundary_fill4(canvas, x, y - 1, fill_color, boundary_color);
lv_canvas_boundary_fill4(canvas, x + 1, y, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x, y + 1, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x - 1, y, boundary_color, fill_color);
lv_canvas_boundary_fill4(canvas, x, y - 1, boundary_color, fill_color);
}
}

View File

@ -164,6 +164,8 @@ void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_c
* @param point1 start point of the line
* @param point2 end point of the line
* @param color color of the line
*
* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.
*/
void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2, lv_color_t color);
@ -197,20 +199,20 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size,
* @param canvas pointer to a canvas object
* @param points edge points of the polygon
* @param size edge count of the polygon
* @param color line color of the polygon
* @param bg_color background color of the polygon
* @param boundary_color line color of the polygon
* @param fill_color fill color of the polygon
*/
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t color, lv_color_t bg_color);
void lv_canvas_fill_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t boundary_color, lv_color_t fill_color);
/**
* Boundary fill function of the canvas
* @param canvas pointer to a canvas object
* @param x x coordinate of the start position (seed)
* @param y y coordinate of the start position (seed)
* @param fill_color fill color of the area
* @param boundary_color edge/boundary color of the area
* @param fill_color fill color of the area
*/
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t boundary_color);
void lv_canvas_boundary_fill4(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t boundary_color, lv_color_t fill_color);
/**
* Flood fill function of the canvas