EasyGUI
gui_draw.h
1 
6 /*
7  * Copyright (c) 2019 Tilen MAJERLE
8  *
9  * Permission is hereby granted, free of charge, to any person
10  * obtaining a copy of this software and associated documentation
11  * files (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
23  * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * This file is part of EasyGUI library.
30  *
31  * Author: Tilen Majerle <tilen@majerle.eu>
32  */
33 #ifndef GUI_HDR_DRAW_H
34 #define GUI_HDR_DRAW_H
35 
36 /* C++ detection */
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
47 #include "gui/gui.h"
48 
59 #define GUI_COLOR_BLUE 0xFF0000FF
60 #define GUI_COLOR_GREEN 0xFF00FF00
61 #define GUI_COLOR_RED 0xFFFF0000
62 #define GUI_COLOR_CYAN 0xFF00FFFF
63 #define GUI_COLOR_MAGENTA 0xFFFF00FF
64 #define GUI_COLOR_YELLOW 0xFFFFFF00
65 #define GUI_COLOR_LIGHTBLUE 0xFF8080FF
66 #define GUI_COLOR_LIGHTGREEN 0xFF80FF80
67 #define GUI_COLOR_LIGHTRED 0xFFFF8080
68 #define GUI_COLOR_LIGHTCYAN 0xFF80FFFF
69 #define GUI_COLOR_LIGHTMAGENTA 0xFFFF80FF
70 #define GUI_COLOR_LIGHTYELLOW 0xFFFFFF80
71 #define GUI_COLOR_DARKBLUE 0xFF000080
72 #define GUI_COLOR_DARKGREEN 0xFF008000
73 #define GUI_COLOR_DARKRED 0xFF800000
74 #define GUI_COLOR_DARKCYAN 0xFF008080
75 #define GUI_COLOR_DARKMAGENTA 0xFF800080
76 #define GUI_COLOR_DARKYELLOW 0xFF808000
77 #define GUI_COLOR_WHITE 0xFFFFFFFF
78 #define GUI_COLOR_LIGHTGRAY 0xFFD3D3D3
79 #define GUI_COLOR_GRAY 0xFF808080
80 #define GUI_COLOR_DARKGRAY 0xFF404040
81 #define GUI_COLOR_BLACK 0xFF000000
82 #define GUI_COLOR_BROWN 0xFFA52A2A
83 #define GUI_COLOR_ORANGE 0xFFFFA500
84 #define GUI_COLOR_TRANS 0x00000000
86 #define GUI_COLOR_ALPHA_0 0x00000000
87 #define GUI_COLOR_ALPHA_5 0x0C000000
88 #define GUI_COLOR_ALPHA_10 0x19000000
89 #define GUI_COLOR_ALPHA_15 0x26000000
90 #define GUI_COLOR_ALPHA_20 0x33000000
91 #define GUI_COLOR_ALPHA_25 0x3F000000
92 #define GUI_COLOR_ALPHA_30 0x4C000000
93 #define GUI_COLOR_ALPHA_35 0x59000000
94 #define GUI_COLOR_ALPHA_40 0x66000000
95 #define GUI_COLOR_ALPHA_45 0x72000000
96 #define GUI_COLOR_ALPHA_50 0x7F000000
97 #define GUI_COLOR_ALPHA_55 0x7C000000
98 #define GUI_COLOR_ALPHA_60 0x99000000
99 #define GUI_COLOR_ALPHA_65 0xA5000000
100 #define GUI_COLOR_ALPHA_70 0xB2000000
101 #define GUI_COLOR_ALPHA_75 0xBF000000
102 #define GUI_COLOR_ALPHA_80 0xCC000000
103 #define GUI_COLOR_ALPHA_85 0xD8000000
104 #define GUI_COLOR_ALPHA_90 0xE5000000
105 #define GUI_COLOR_ALPHA_95 0xF2000000
106 #define GUI_COLOR_ALPHA_100 0xFF000000
108 #define GUI_COLOR_WIN_DARKGRAY 0xFF555555
109 #define GUI_COLOR_WIN_MIDDLEGRAY 0xFF848484
110 #define GUI_COLOR_WIN_LIGHTGRAY 0xFFC6C6C6
112 #define GUI_COLOR_WIN_BLUE 0xFF5590B7
113 #define GUI_COLOR_WIN_RED 0xFFD14752
115 #define GUI_COLOR_WIN_BG GUI_COLOR_WHITE
116 #define GUI_COLOR_WIN_TEXT GUI_COLOR_BLACK
117 #define GUI_COLOR_WIN_TEXT_TITLE GUI_COLOR_BLACK
118 #define GUI_COLOR_WIN_SEL_FOC GUI_COLOR_WHITE
119 #define GUI_COLOR_WIN_SEL_NOFOC GUI_COLOR_WHITE
120 #define GUI_COLOR_WIN_SEL_FOC_BG GUI_COLOR_BLUE
121 #define GUI_COLOR_WIN_SEL_NOFOC_BG GUI_COLOR_WIN_MIDDLEGRAY
130 #define GUI_COLOR_ALPHA(c, a) (((c) & 0x00FFFFFFUL) | (a))
131 
136 #define GUI_DRAW_CIRCLE_TL 0x01
137 #define GUI_DRAW_CIRCLE_TR 0x02
138 #define GUI_DRAW_CIRCLE_BR 0x04
139 #define GUI_DRAW_CIRCLE_BL 0x08
145 typedef struct {
150  uint8_t align;
152  uint8_t flags;
156  uint32_t scrolly;
158 
159 #define GUI_FLAG_DRAW_GRAD_VER 0x01
160 #define GUI_FLAG_DRAW_GRAD_HOR 0x02
161 #define GUI_FLAG_DRAW_FILLED 0x04
162 
166 typedef struct {
171  uint8_t flags;
176 
180 typedef enum {
184 
188 typedef struct {
194  uint32_t entriestotal;
195  uint32_t entriesvisible;
196  uint32_t entriestop;
197 } gui_draw_sb_t;
198 
203 typedef enum {
207 
212 typedef struct {
216 
218 void gui_draw_fillscreen(const gui_display_t* disp, gui_color_t color);
219 void gui_draw_setpixel(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_color_t color);
221 void gui_draw_vline(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t length, gui_color_t color);
222 void gui_draw_hline(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t length, gui_color_t color);
223 void gui_draw_line(const gui_display_t* disp, gui_dim_t x1, gui_dim_t y1, gui_dim_t x2, gui_dim_t y2, gui_color_t color);
224 void gui_draw_rectangle(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_color_t color);
226 void gui_draw_filledrectangle(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_color_t color);
227 void gui_draw_roundedrectangle(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_dim_t r, gui_color_t color);
229 void gui_draw_circle(const gui_display_t* disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, gui_color_t color);
230 void gui_draw_filledcircle(const gui_display_t* disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, gui_color_t color);
231 void gui_draw_circlecorner(const gui_display_t* disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, uint8_t c, gui_color_t color);
232 void gui_draw_filledcirclecorner(const gui_display_t* disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, uint8_t c, uint32_t color);
233 void gui_draw_triangle(const gui_display_t* disp, gui_dim_t x1, gui_dim_t y1, gui_dim_t x2, gui_dim_t y2, gui_dim_t x3, gui_dim_t y3, gui_color_t color);
235 void gui_draw_image(gui_display_t* disp, gui_dim_t x, gui_dim_t y, const gui_image_desc_t* img);
236 void gui_draw_writetext(const gui_display_t* disp, const gui_font_t* font, const gui_char* str, gui_draw_text_t* draw);
237 void gui_draw_rectangle3d(const gui_display_t* disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_draw_3d_state_t state);
238 void gui_draw_poly(const gui_display_t* disp, const gui_draw_poly_t* points, size_t len, gui_color_t color);
240 void gui_draw_scrollbar(const gui_display_t* disp, gui_draw_sb_t* sb);
241 
246 /* C++ detection */
247 #ifdef __cplusplus
248 }
249 #endif
250 
251 #endif /* GUI_HDR_DRAW_H */
Extended rectangle structure.
Definition: gui_draw.h:166
Definition: gui_draw.h:204
gui_draw_sb_dir_t dir
Definition: gui_draw.h:193
void gui_draw_scrollbar(const gui_display_t *disp, gui_draw_sb_t *sb)
Draw scroll bar to screen.
Definition: gui_draw.c:1278
gui_draw_sb_dir_t
Scroll bar direction enumeration.
Definition: gui_draw.h:180
gui_color_t gui_draw_getpixel(const gui_display_t *disp, gui_dim_t x, gui_dim_t y)
Get pixel color at X and Y location.
Definition: gui_draw.c:546
gui_color_t color
Definition: gui_draw.h:172
gui_dim_t x
Definition: gui_draw.h:167
gui_draw_3d_state_t
3D states enumeration
Definition: gui_draw.h:203
void gui_draw_triangle(const gui_display_t *disp, gui_dim_t x1, gui_dim_t y1, gui_dim_t x2, gui_dim_t y2, gui_dim_t x3, gui_dim_t y3, gui_color_t color)
Draw triangle.
Definition: gui_draw.c:883
void gui_draw_poly(const gui_display_t *disp, const gui_draw_poly_t *points, size_t len, gui_color_t color)
Draw polygon lines.
Definition: gui_draw.c:1156
gui_color_t color_end
Definition: gui_draw.h:173
uint8_t gui_char
Definition: gui_defs.h:212
void gui_draw_hline(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t length, gui_color_t color)
Draw horizontal line to LCD.
Definition: gui_draw.c:584
Definition: gui_draw.h:205
Poly line object coordinates.
Definition: gui_draw.h:212
void gui_draw_scrollbar_init(gui_draw_sb_t *sb)
Initializes gui_draw_sb_t structure for drawing operations.
Definition: gui_draw.c:1268
uint32_t entriesvisible
Definition: gui_draw.h:195
void gui_draw_filledroundedrectangle(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_dim_t r, gui_color_t color)
Draw filled rectangle with rounded corners.
Definition: gui_draw.c:811
void gui_draw_setpixel(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_color_t color)
Set single pixel at X and Y location.
Definition: gui_draw.c:530
void gui_draw_roundedrectangle(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_dim_t r, gui_color_t color)
Draw rectangle with rounded corners.
Definition: gui_draw.c:777
uint8_t flags
Definition: gui_draw.h:152
void gui_draw_writetext(const gui_display_t *disp, const gui_font_t *font, const gui_char *str, gui_draw_text_t *draw)
Write text to screen.
Definition: gui_draw.c:1181
uint32_t gui_color_t
Definition: gui_defs.h:210
Definition: gui_draw.h:182
void gui_draw_circle(const gui_display_t *disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, gui_color_t color)
Draw circle.
Definition: gui_draw.c:846
gui_dim_t lineheight
Definition: gui_draw.h:151
void gui_draw_vline(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t length, gui_color_t color)
Draw vertical line to LCD.
Definition: gui_draw.c:560
gui_color_t color2
Definition: gui_draw.h:155
uint32_t scrolly
Definition: gui_draw.h:156
GUI clipping management.
Definition: gui_defs.h:364
gui_dim_t height
Definition: gui_draw.h:170
uint32_t entriestop
Definition: gui_draw.h:196
uint8_t align
Definition: gui_draw.h:150
gui_dim_t x
Definition: gui_draw.h:189
void gui_draw_image(gui_display_t *disp, gui_dim_t x, gui_dim_t y, const gui_image_desc_t *img)
Draw image to display of any depth and size.
Definition: gui_draw.c:1085
void gui_draw_line(const gui_display_t *disp, gui_dim_t x1, gui_dim_t y1, gui_dim_t x2, gui_dim_t y2, gui_color_t color)
Draw line from point 1 to point 2.
Definition: gui_draw.c:615
gui_dim_t width
Definition: gui_draw.h:148
gui_dim_t height
Definition: gui_draw.h:149
void gui_draw_circlecorner(const gui_display_t *disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, uint8_t c, gui_color_t color)
Draw circle corner, selected with parameter.
Definition: gui_draw.c:973
gui_dim_t x
Definition: gui_draw.h:213
gui_dim_t width
Definition: gui_draw.h:169
gui_dim_t y
Definition: gui_draw.h:168
FONT structure for writing usage.
Definition: gui_defs.h:473
gui_dim_t width
Definition: gui_draw.h:191
gui_dim_t color1width
Definition: gui_draw.h:153
void gui_draw_rectangle_ex(const gui_display_t *disp, gui_draw_rect_ex_t *rect)
Draw rectangle extended function.
Definition: gui_draw.c:693
void gui_draw_filledcirclecorner(const gui_display_t *disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, uint8_t c, uint32_t color)
Draw filled circle corner, selected with parameter.
Definition: gui_draw.c:1034
void gui_draw_filledcircle(const gui_display_t *disp, gui_dim_t x0, gui_dim_t y0, gui_dim_t r, gui_color_t color)
Draw filled circle.
Definition: gui_draw.c:863
gui_dim_t y
Definition: gui_draw.h:190
int16_t gui_dim_t
Definition: gui_defs.h:211
Definition: gui_draw.h:181
gui_color_t color1
Definition: gui_draw.h:154
gui_dim_t radius
Definition: gui_draw.h:174
gui_dim_t x
Definition: gui_draw.h:146
void gui_draw_text_init(gui_draw_text_t *f)
Initialize gui_draw_text_t structure for further usage.
Definition: gui_draw.c:507
gui_dim_t height
Definition: gui_draw.h:192
void gui_draw_fillscreen(const gui_display_t *disp, gui_color_t color)
Fill screen with color.
Definition: gui_draw.c:517
void gui_draw_filledtriangle(const gui_display_t *disp, gui_dim_t x1, gui_dim_t y1, gui_dim_t x2, gui_dim_t y2, gui_dim_t x3, gui_dim_t y3, gui_color_t color)
Draw filled triangle.
Definition: gui_draw.c:902
Structure for drawing strings on widgets.
Definition: gui_draw.h:145
Image descriptor structure.
Definition: gui_defs.h:404
void gui_draw_filledrectangle(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_color_t color)
Draw filled rectangle.
Definition: gui_draw.c:730
gui_dim_t y
Definition: gui_draw.h:147
gui_dim_t y
Definition: gui_draw.h:214
void gui_draw_rectangle3d(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_draw_3d_state_t state)
Draw rectangle with 3D view.
Definition: gui_draw.c:744
uint32_t entriestotal
Definition: gui_draw.h:194
void gui_draw_rectangle(const gui_display_t *disp, gui_dim_t x, gui_dim_t y, gui_dim_t width, gui_dim_t height, gui_color_t color)
Draw rectangle.
Definition: gui_draw.c:708
Scroll bar structure.
Definition: gui_draw.h:188