microui  14.5.5
microui
ui_color.h
Go to the documentation of this file.
1 /*
2  * C
3  *
4  * Copyright 2020-2026 MicroEJ Corp. All rights reserved.
5  * MicroEJ Corp. PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */
7 
8 #if !defined UI_COLOR_H
9 #define UI_COLOR_H
10 #if defined __cplusplus
11 extern "C" {
12 #endif
13 
22 // -----------------------------------------------------------------------------
23 // Macros and Defines
24 // -----------------------------------------------------------------------------
25 
29 #define COLOR_ARGB8888_CHANNEL_SIZE 8
30 
34 #define COLOR_ARGB8888_CHANNEL_MASK \
35  ((1 << COLOR_ARGB8888_CHANNEL_SIZE) - 1)
36 
43 #define COLOR_CHANNEL_MASK(format, channel) \
44  ((1 << COLOR_CHANNEL_SIZE(format, channel)) - 1)
45 
52 #define COLOR_CHANNEL_SIZE(format, channel) \
53  COLOR_ ## format ## _ ## channel ## _SIZE
54 
61 #define COLOR_CHANNEL_OFFSET(format, channel) \
62  COLOR_ ## format ## _ ## channel ## _OFFSET
63 
67 #define COLOR_ARGB8888_ALPHA_SIZE COLOR_ARGB8888_CHANNEL_SIZE
68 
72 #define COLOR_ARGB8888_ALPHA_OFFSET 24
73 
77 #define COLOR_ARGB8888_ALPHA_MASK \
78  COLOR_CHANNEL_MASK(ARGB8888, ALPHA)
79 
83 #define COLOR_ARGB8888_RED_SIZE COLOR_ARGB8888_CHANNEL_SIZE
84 
88 #define COLOR_ARGB8888_RED_OFFSET 16
89 
93 #define COLOR_ARGB8888_RED_MASK \
94  COLOR_CHANNEL_MASK(ARGB8888, RED)
95 
99 #define COLOR_ARGB8888_GREEN_SIZE COLOR_ARGB8888_CHANNEL_SIZE
100 
104 #define COLOR_ARGB8888_GREEN_OFFSET 8
105 
109 #define COLOR_ARGB8888_GREEN_MASK \
110  COLOR_CHANNEL_MASK(ARGB8888, GREEN)
111 
115 #define COLOR_ARGB8888_BLUE_SIZE COLOR_ARGB8888_CHANNEL_SIZE
116 
120 #define COLOR_ARGB8888_BLUE_OFFSET 0
121 
125 #define COLOR_ARGB8888_BLUE_MASK \
126  COLOR_CHANNEL_MASK(ARGB8888, BLUE)
127 
134 #define COLOR_GET_CHANNEL(color, format, channel) \
135  (uint8_t)( \
136  ((color) >> COLOR_CHANNEL_OFFSET(format, channel)) \
137  &COLOR_CHANNEL_MASK(format, channel) \
138  )
139 
149 #define COLOR_SET_COLOR(alpha, red, green, blue, format) \
150  (uint32_t)(0 \
151  | (((alpha)&COLOR_ ## format ## _ALPHA_MASK) \
152  << (COLOR_ ## format ## _ALPHA_OFFSET)) \
153  | (((red)&COLOR_ ## format ## _RED_MASK) \
154  << (COLOR_ ## format ## _RED_OFFSET)) \
155  | (((green)&COLOR_ ## format ## _GREEN_MASK) \
156  << (COLOR_ ## format ## _GREEN_OFFSET)) \
157  | (((blue)&COLOR_ ## format ## _BLUE_MASK) \
158  << (COLOR_ ## format ## _BLUE_OFFSET)) \
159  )
160 
161 // -----------------------------------------------------------------------------
162 // EOF
163 // -----------------------------------------------------------------------------
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif // !defined UI_COLOR_H