/**1* @file lv_canvas.h2*3*/45#ifndef LV_CANVAS_H6#define LV_CANVAS_H78#ifdef __cplusplus9extern "C" {10#endif1112/*********************13* INCLUDES14*********************/15#ifdef LV_CONF_INCLUDE_SIMPLE16#include "lv_conf.h"17#else18#include "../../lv_conf.h"19#endif2021#if USE_LV_CANVAS != 02223#include "../lv_core/lv_obj.h"24#include "../lv_objx/lv_img.h"2526/*********************27* DEFINES28*********************/2930/**********************31* TYPEDEFS32**********************/33/*Data of canvas*/34typedef struct {35lv_img_ext_t img; /*Ext. of ancestor*/36/*New data for this type */37lv_img_dsc_t dsc;38} lv_canvas_ext_t;394041/*Styles*/42enum {43LV_CANVAS_STYLE_MAIN,44};45typedef uint8_t lv_canvas_style_t;464748/**********************49* GLOBAL PROTOTYPES50**********************/5152/**53* Create a canvas object54* @param par pointer to an object, it will be the parent of the new canvas55* @param copy pointer to a canvas object, if not NULL then the new object will be copied from it56* @return pointer to the created canvas57*/58lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy);5960/*=====================61* Setter functions62*====================*/6364/**65* Set a buffer for the canvas.66* @param buf a buffer where the content of the canvas will be.67* The required size is (lv_img_color_format_get_px_size(cf) * w * h) / 8)68* It can be allocated with `lv_mem_alloc()` or69* it can be statically allocated array (e.g. static lv_color_t buf[100*50]) or70* it can be an address in RAM or external SRAM71* @param canvas pointer to a canvas object72* @param w width of the canvas73* @param h height of the canvas74* @param cf color format. The following formats are supported:75* LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT76*/77void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);7879/**80* Set the color of a pixel on the canvas81* @param canvas82* @param x x coordinate of the point to set83* @param y x coordinate of the point to set84* @param c color of the point85*/86void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);8788/**89* Set a style of a canvas.90* @param canvas pointer to canvas object91* @param type which style should be set92* @param style pointer to a style93*/94void lv_canvas_set_style(lv_obj_t * canvas, lv_canvas_style_t type, lv_style_t * style);9596/*=====================97* Getter functions98*====================*/99100/**101* Get the color of a pixel on the canvas102* @param canvas103* @param x x coordinate of the point to set104* @param y x coordinate of the point to set105* @return color of the point106*/107lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y);108109/**110* Get style of a canvas.111* @param canvas pointer to canvas object112* @param type which style should be get113* @return style pointer to the style114*/115lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_t type);116117/*=====================118* Other functions119*====================*/120121/**122* Copy a buffer to the canvas123* @param canvas pointer to a canvas object124* @param to_copy buffer to copy. The color format has to match with the canvas's buffer color format125* @param w width of the buffer to copy126* @param h height of the buffer to copy127* @param x left side of the destination position128* @param y top side of the destination position129*/130void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);131132/**133* Multiply a buffer with the canvas134* @param canvas pointer to a canvas object135* @param to_copy buffer to copy (multiply). LV_IMG_CF_TRUE_COLOR_ALPHA is not supported136* @param w width of the buffer to copy137* @param h height of the buffer to copy138* @param x left side of the destination position139* @param y top side of the destination position140*/141void lv_canvas_mult_buf(lv_obj_t * canvas, void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y);142143/**144* Draw circle function of the canvas145* @param canvas pointer to a canvas object146* @param x0 x coordinate of the circle147* @param y0 y coordinate of the circle148* @param radius radius of the circle149* @param color border color of the circle150*/151void lv_canvas_draw_circle(lv_obj_t * canvas, lv_coord_t x0, lv_coord_t y0, lv_coord_t radius, lv_color_t color);152153/**154* Draw line function of the canvas155* @param canvas pointer to a canvas object156* @param point1 start point of the line157* @param point2 end point of the line158* @param color color of the line159*160* NOTE: The lv_canvas_draw_line function originates from https://github.com/jb55/bresenham-line.c.161*/162void lv_canvas_draw_line(lv_obj_t * canvas, lv_point_t point1, lv_point_t point2, lv_color_t color);163164/**165* Draw triangle function of the canvas166* @param canvas pointer to a canvas object167* @param points edge points of the triangle168* @param color line color of the triangle169*/170void lv_canvas_draw_triangle(lv_obj_t * canvas, lv_point_t * points, lv_color_t color);171172/**173* Draw rectangle function of the canvas174* @param canvas pointer to a canvas object175* @param points edge points of the rectangle176* @param color line color of the rectangle177*/178void lv_canvas_draw_rect(lv_obj_t * canvas, lv_point_t * points, lv_color_t color);179180/**181* Draw polygon function of the canvas182* @param canvas pointer to a canvas object183* @param points edge points of the polygon184* @param size edge count of the polygon185* @param color line color of the polygon186*/187void lv_canvas_draw_polygon(lv_obj_t * canvas, lv_point_t * points, size_t size, lv_color_t color);188189/**190* Fill polygon function of the canvas191* @param canvas pointer to a canvas object192* @param points edge points of the polygon193* @param size edge count of the polygon194* @param boundary_color line color of the polygon195* @param fill_color fill color of the polygon196*/197void 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);198/**199* Boundary fill function of the canvas200* @param canvas pointer to a canvas object201* @param x x coordinate of the start position (seed)202* @param y y coordinate of the start position (seed)203* @param boundary_color edge/boundary color of the area204* @param fill_color fill color of the area205*/206void 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);207208/**209* Flood fill function of the canvas210* @param canvas pointer to a canvas object211* @param x x coordinate of the start position (seed)212* @param y y coordinate of the start position (seed)213* @param fill_color fill color of the area214* @param bg_color background color of the area215*/216void lv_canvas_flood_fill(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t fill_color, lv_color_t bg_color);217218/**********************219* MACROS220**********************/221222#endif /*USE_LV_CANVAS*/223224#ifdef __cplusplus225} /* extern "C" */226#endif227228#endif /*LV_CANVAS_H*/229230231