初始化配色方案
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LENGTH(X) (sizeof(X) / sizeof(X)[0])
|
||||
|
||||
@@ -12,3 +13,28 @@ void die(const char *format, ...);
|
||||
void *ecalloc(size_t number_of_member, size_t member_size);
|
||||
|
||||
bool file_exist(const char *path);
|
||||
|
||||
/**
|
||||
* @brief 将 16 进制的颜色配置转换成 uint32 格式的 rgba数据
|
||||
*
|
||||
* @param hex 16 进制的颜色表示,支持的格式有
|
||||
* RGB/RGBA/RRGGBB/RRGGBBAA/#RGB/#RGBA/#RRGGBB/#RRGGBBAA
|
||||
* @param rgba 返回数据的指针,解析结果会放到这个指针指向的内存中
|
||||
* @return 如果 hex 是一个能正常解析的颜色,返回 true ,否则返回 false
|
||||
*/
|
||||
bool hex_color_to_rgba(const char *hex, uint32_t *rgba);
|
||||
/**
|
||||
* @brief 将 rgba 通道顺序的颜色转换成 argb 顺序
|
||||
* @description xcb 库用到的颜色需要是 argb 通道顺序
|
||||
*/
|
||||
uint32_t rgba_to_argb(uint32_t rgba);
|
||||
/**
|
||||
* @brief 提取颜色中的各个颜色通道数值
|
||||
* @param rgba uint32 表示的颜色
|
||||
* @param red red channel, range 0~1
|
||||
* @param green green channel, range 0~1
|
||||
* @param blue blue channel, range 0~1
|
||||
* @param alpha alpha channel, range 0~1
|
||||
*/
|
||||
void extract_color_channel(const uint32_t rgba, double *red, double *green,
|
||||
double *blue, double *alpha);
|
||||
|
||||
Reference in New Issue
Block a user