VSF Documented
vsf_tgui_sv_color.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TINY_GUI_COLOR_H__
19#define __VSF_TINY_GUI_COLOR_H__
20
21/*============================ INCLUDES ======================================*/
22#include "../../vsf_tgui_cfg.h"
23
24#if VSF_USE_TINY_GUI == ENABLED
25/*============================ MACROS ========================================*/
26
27#ifndef VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA
28# define VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA ENABLED
29#endif
30
31#if VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_ARGB_8888
32# undef VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA
33# define VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA ENABLED
34#endif
35
36#if VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA == ENABLED
37# define __VSF_TGUI_COLOR_RGBA(__R, __G, __B, __A) ((vsf_tgui_sv_color_t){.red = __R, .green = __G, .blue = __B, .alpha = __A})
38#else
39# define __VSF_TGUI_COLOR_RGBA(__R, __G, __B, __A) ((vsf_tgui_sv_color_t){.red = __R, .green = __G, .blue = __B,})
40#endif
41
42#if VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_ARGB_8888
43# define VSF_TGUI_COLOR_RGBA(__R, __G, __B, __A) __VSF_TGUI_COLOR_RGBA(__R, __G, __B, __A)
44#elif VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_RGB16_565
45# define VSF_TGUI_COLOR_RGBA(__R, __G, __B, __A) __VSF_TGUI_COLOR_RGBA(__R >> 3, __G >> 2, __B >> 3, __A)
46#else
47# error "TODO: add more color support"
48#endif
49#define VSF_TGUI_COLOR_RGB(__R, __G, __B) VSF_TGUI_COLOR_RGBA(__R, __G, __B, 0xFF)
50
51#define VSF_TGUI_COLOR_WHITE VSF_TGUI_COLOR_RGB(0xFF, 0xFF, 0xFF) // Red:100% Green:100% Blue:100%
52#define VSF_TGUI_COLOR_SILVER VSF_TGUI_COLOR_RGB(0xC0, 0xC0, 0xC0) // Red: 75% Green: 75% Blue: 75%
53#define VSF_TGUI_COLOR_GRAY VSF_TGUI_COLOR_RGB(0x80, 0x80, 0x80) // Red: 50% Green: 50% Blue: 50%
54#define VSF_TGUI_COLOR_BLACK VSF_TGUI_COLOR_RGB(0x00, 0x00, 0x00) // Red: 0% Green: 0% Blue: 0%
55#define VSF_TGUI_COLOR_RED VSF_TGUI_COLOR_RGB(0xFF, 0x00, 0x00) // Red:100% Green: 0% Blue: 0%
56#define VSF_TGUI_COLOR_MAROON VSF_TGUI_COLOR_RGB(0x80, 0x00, 0x00) // Red: 50% Green: 0% Blue: 0%
57#define VSF_TGUI_COLOR_YELLOW VSF_TGUI_COLOR_RGB(0xFF, 0xFF, 0x00) // Red:100% Green:100% Blue: 0%
58#define VSF_TGUI_COLOR_OLIVE VSF_TGUI_COLOR_RGB(0x80, 0x80, 0x00) // Red: 50% Green: 50% Blue: 0%
59#define VSF_TGUI_COLOR_LIME VSF_TGUI_COLOR_RGB(0x00, 0xFF, 0x00) // Red: 0% Green:100% Blue: 0%
60#define VSF_TGUI_COLOR_GREEN VSF_TGUI_COLOR_RGB(0x00, 0x80, 0x00) // Red: 0% Green: 50% Blue: 0%
61#define VSF_TGUI_COLOR_AQUA VSF_TGUI_COLOR_RGB(0x00, 0xFF, 0xFF) // Red: 0% Green:100% Blue:100%
62#define VSF_TGUI_COLOR_TEAL VSF_TGUI_COLOR_RGB(0x00, 0x80, 0x80) // Red: 0% Green: 50% Blue: 50%
63#define VSF_TGUI_COLOR_BLUE VSF_TGUI_COLOR_RGB(0x00, 0x00, 0xFF) // Red: 0% Green: 0% Blue:100%
64#define VSF_TGUI_COLOR_NAVY VSF_TGUI_COLOR_RGB(0x00, 0x00, 0x80) // Red: 0% Green: 0% Blue: 50%
65#define VSF_TGUI_COLOR_FUCHSIA VSF_TGUI_COLOR_RGB(0xFF, 0x00, 0xFF) // Red:100% Green: 0% Blue:100%
66#define VSF_TGUI_COLOR_PURPLE VSF_TGUI_COLOR_RGB(0x80, 0x00, 0x80) // Red: 50% Green: 0% Blue: 50%
67
68/*============================ MACROFIED FUNCTIONS ===========================*/
69/*============================ TYPES =========================================*/
71 union {
73 struct {
77 };
78 };
79#if VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA == ENABLED
81#endif
83
85 union {
87 struct {
91 };
92 };
93#if VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA == ENABLED
95#endif
97
100 struct {
105 };
107
108#if VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_BGR_565
110#elif VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_RGB_565
112#elif VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_ARGB_8888
114#else
115typedef VSF_TGUI_CFG_COLOR_TYPE vsf_tgui_sv_color_t;
116#endif
117
118/*============================ GLOBAL VARIABLES ==============================*/
119/*============================ PROTOTYPES ====================================*/
121
125
129
133
134#endif
135
136#endif
137/* EOF */
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_tgui_sv_color.h:84
uint16_t blue
Definition vsf_tgui_sv_color.h:90
uint16_t value
Definition vsf_tgui_sv_color.h:86
uint16_t red
Definition vsf_tgui_sv_color.h:88
uint8_t alpha
Definition vsf_tgui_sv_color.h:94
uint16_t green
Definition vsf_tgui_sv_color.h:89
Definition vsf_tgui_sv_color.h:70
uint16_t blue
Definition vsf_tgui_sv_color.h:74
uint8_t alpha
Definition vsf_tgui_sv_color.h:80
uint16_t value
Definition vsf_tgui_sv_color.h:72
uint16_t red
Definition vsf_tgui_sv_color.h:76
uint16_t green
Definition vsf_tgui_sv_color.h:75
Definition vsf_tgui_sv_color.h:98
uint8_t red
Definition vsf_tgui_sv_color.h:103
uint8_t green
Definition vsf_tgui_sv_color.h:102
uint8_t blue
Definition vsf_tgui_sv_color.h:101
uint32_t value
Definition vsf_tgui_sv_color.h:99
uint8_t alpha
Definition vsf_tgui_sv_color.h:104
uint32_t color
Definition vsf_sdl2_pixelformat.c:31
vsf_tgui_sv_color_t vsf_tgui_sv_argb8888_to_color(vsf_tgui_sv_color_argb8888_t argb8888_color)
Definition vsf_tgui_sv_color.c:73
vsf_tgui_sv_color_argb8888_t vsf_tgui_sv_color_to_argb8888(vsf_tgui_sv_color_t color)
Definition vsf_tgui_sv_color.c:92
void vsf_tgui_sv_color_set_trans_rate(vsf_tgui_sv_color_t *color_ptr, uint_fast8_t alpha)
Definition vsf_tgui_sv_color.c:66
vsf_tgui_sv_color_t vsf_tgui_sv_bgr565_to_color(vsf_tgui_sv_color_bgr565_t bgr565_color)
Definition vsf_tgui_sv_color.c:168
uint_fast8_t vsf_tgui_sv_color_get_trans_rate(vsf_tgui_sv_color_t color)
Definition vsf_tgui_sv_color.c:57
vsf_tgui_sv_color_rgb565_t vsf_tgui_sv_color_to_rgb565(vsf_tgui_sv_color_t color)
Definition vsf_tgui_sv_color.c:139
vsf_tgui_sv_color_t vsf_tgui_sv_rgb565_to_color(vsf_tgui_sv_color_rgb565_t rgb565_color)
Definition vsf_tgui_sv_color.c:112
vsf_tgui_sv_color_bgr565_t vsf_tgui_sv_color_t
Definition vsf_tgui_sv_color.h:109
bool vsf_tgui_sv_color_is_opaque(vsf_tgui_sv_color_t color)
Definition vsf_tgui_sv_color.c:48
vsf_tgui_sv_color_t vsf_tgui_sv_color_mix(vsf_tgui_sv_color_t color_0, vsf_tgui_sv_color_t color_1, uint_fast8_t mix)
vsf_tgui_sv_color_bgr565_t vsf_tgui_sv_color_to_bgr565(vsf_tgui_sv_color_t color)
Definition vsf_tgui_sv_color.c:195