2016-06-08 07:25:08 +02:00
|
|
|
/**
|
2017-04-10 11:33:38 +02:00
|
|
|
* @file lv_draw.h
|
2016-06-08 07:25:08 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_DRAW_H
|
|
|
|
#define LV_DRAW_H
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_style.h"
|
2017-11-26 11:38:28 +01:00
|
|
|
#include "../lv_misc/lv_txt.h"
|
2017-01-02 10:48:21 +01:00
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
2018-02-23 13:56:04 +01:00
|
|
|
/*If image pixels contains alpha we need to know how much byte is a pixel*/
|
|
|
|
#if LV_COLOR_DEPTH == 1 || LV_COLOR_DEPTH == 8
|
|
|
|
# define LV_IMG_PX_SIZE_ALPHA_BYTE 2
|
|
|
|
#elif LV_COLOR_DEPTH == 16
|
|
|
|
# define LV_IMG_PX_SIZE_ALPHA_BYTE 3
|
|
|
|
#elif LV_COLOR_DEPTH == 24
|
|
|
|
# define LV_IMG_PX_SIZE_ALPHA_BYTE 4
|
|
|
|
#endif
|
2016-06-08 07:25:08 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2017-08-21 14:55:06 +02:00
|
|
|
/* Image header it is compatible with
|
|
|
|
* the result image converter utility*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2018-02-23 13:56:04 +01:00
|
|
|
union{
|
|
|
|
struct {
|
|
|
|
uint32_t chroma_keyed:1; /*1: The image contains transparent pixels with LV_COLOR_TRANSP color*/
|
|
|
|
uint32_t alpha_byte :1; /*Every pixel is extended with a 8 bit alpha channel*/
|
|
|
|
uint32_t format :6; /*See: lv_img_px_format*/
|
|
|
|
uint32_t w:12; /*Width of the image map*/
|
|
|
|
uint32_t h:12; /*Height of the image map*/
|
|
|
|
}header;
|
|
|
|
uint8_t src_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
union {
|
|
|
|
const uint8_t * pixel_map; /*For internal images (c arrays) pointer to the pixels array*/
|
|
|
|
uint8_t first_pixel; /*For external images (binary) the first byte of the pixels (just for convenient)*/
|
|
|
|
};
|
|
|
|
}lv_img_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LV_IMG_FORMAT_UNKOWN = 0,
|
2018-02-23 15:22:23 +01:00
|
|
|
LV_IMG_FORMAT_INTERNAL_RAW, /*'lv_img_t' variable compiled with the code*/
|
2018-02-23 13:56:04 +01:00
|
|
|
LV_IMG_FORMAT_FILE_RAW_RGB332, /*8 bit*/
|
|
|
|
LV_IMG_FORMAT_FILE_RAW_RGB565, /*16 bit*/
|
|
|
|
LV_IMG_FORMAT_FILE_RAW_RGB888, /*24 bit (stored on 32 bit)*/
|
|
|
|
}lv_img_format_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LV_IMG_SRC_VARIABLE,
|
|
|
|
LV_IMG_SRC_FILE,
|
|
|
|
LV_IMG_SRC_SYMBOL,
|
|
|
|
LV_IMG_SRC_UNKNOWN,
|
|
|
|
}lv_img_src_t;
|
2018-02-09 12:40:00 +01:00
|
|
|
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a rectangle
|
|
|
|
* @param cords_p the coordinates of the rectangle
|
|
|
|
* @param mask_p the rectangle will be drawn only in this mask
|
2017-04-13 10:20:35 +02:00
|
|
|
* @param style_p pointer to a style
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-11-23 21:28:36 +01:00
|
|
|
void lv_draw_rect(const lv_area_t * cords_p, const lv_area_t * mask_p, const lv_style_t * style_p);
|
2017-01-02 15:29:05 +01:00
|
|
|
|
2017-02-17 11:29:17 +01:00
|
|
|
|
|
|
|
/*Experimental use for 3D modeling*/
|
2018-05-20 21:27:57 +02:00
|
|
|
#define USE_LV_TRIANGLE 1
|
2017-02-17 11:29:17 +01:00
|
|
|
#if USE_LV_TRIANGLE != 0
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param points pointer to an array with 3 points
|
|
|
|
* @param mask_p the triangle will be drawn only in this mask
|
|
|
|
* @param color color of the triangle
|
|
|
|
*/
|
2017-11-23 21:28:36 +01:00
|
|
|
void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask_p, lv_color_t color);
|
2017-02-17 11:29:17 +01:00
|
|
|
#endif
|
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Write a text
|
|
|
|
* @param cords_p coordinates of the label
|
|
|
|
* @param mask_p the label will be drawn only in this area
|
2017-04-13 10:20:35 +02:00
|
|
|
* @param style_p pointer to a style
|
2017-01-13 23:27:49 +01:00
|
|
|
* @param txt 0 terminated text to write
|
2017-02-01 11:39:48 +01:00
|
|
|
* @param flags settings for the text from 'txt_flag_t' enum
|
2017-06-18 18:25:25 +02:00
|
|
|
* @param offset text offset in x and y direction (NULL if unused)
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-11-23 21:28:36 +01:00
|
|
|
void lv_draw_label(const lv_area_t * cords_p,const lv_area_t * mask_p, const lv_style_t * style_p,
|
2017-11-24 17:48:47 +01:00
|
|
|
const char * txt, lv_txt_flag_t flag, lv_point_t * offset);
|
2017-01-02 15:29:05 +01:00
|
|
|
|
2017-11-27 17:48:54 +01:00
|
|
|
#if USE_LV_IMG
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Draw an image
|
|
|
|
* @param cords_p the coordinates of the image
|
|
|
|
* @param mask_p the image will be drawn only in this area
|
2017-11-23 21:28:36 +01:00
|
|
|
* @param map_p pointer to a lv_color_t array which contains the pixels of the image
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2018-02-09 12:40:00 +01:00
|
|
|
void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask,
|
2018-02-23 13:56:04 +01:00
|
|
|
const lv_style_t * style, const void * src);
|
2017-11-27 17:48:54 +01:00
|
|
|
#endif
|
2017-01-02 10:48:21 +01:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Draw a line
|
|
|
|
* @param p1 first point of the line
|
|
|
|
* @param p2 second point of the line
|
|
|
|
* @param mask_pthe line will be drawn only on this area
|
2017-04-13 10:20:35 +02:00
|
|
|
* @param style_p pointer to a style
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-11-23 21:28:36 +01:00
|
|
|
void lv_draw_line(const lv_point_t * p1, const lv_point_t * p2, const lv_area_t * mask_p,
|
2017-04-13 10:20:35 +02:00
|
|
|
const lv_style_t * style_p);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2018-05-20 21:27:57 +02:00
|
|
|
|
|
|
|
/**********************
|
|
|
|
* GLOBAL VARIABLES
|
|
|
|
**********************/
|
|
|
|
void (*px_fp)(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
|
|
|
void (*fill_fp)(const lv_area_t * coords, const lv_area_t * mask, lv_color_t color, lv_opa_t opa);
|
|
|
|
void (*letter_fp)(const lv_point_t * pos_p, const lv_area_t * mask, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa);
|
|
|
|
void (*map_fp)(const lv_area_t * cords_p, const lv_area_t * mask_p,
|
|
|
|
const uint8_t * map_p, lv_opa_t opa, bool chroma_key, bool alpha_byte,
|
|
|
|
lv_color_t recolor, lv_opa_t recolor_opa);
|
|
|
|
|
2016-06-08 07:25:08 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
2016-06-08 07:25:08 +02:00
|
|
|
#endif
|
2017-07-09 15:32:49 +02:00
|
|
|
|
|
|
|
#endif /*LV_DRAW_H*/
|