2022-03-21 21:51:23 -04:00
|
|
|
#ifndef COLOR_H
|
|
|
|
#define COLOR_H
|
|
|
|
|
2022-07-31 14:50:28 -04:00
|
|
|
#include <stdint.h>
|
2022-07-27 17:50:56 -04:00
|
|
|
#include "endianness.h"
|
|
|
|
|
2022-07-31 14:50:28 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
typedef struct {
|
2022-07-25 23:11:45 -04:00
|
|
|
uint8_t r, g, b;
|
2022-03-21 21:51:23 -04:00
|
|
|
} Color_RGB8;
|
|
|
|
|
|
|
|
typedef struct {
|
2022-07-25 23:11:45 -04:00
|
|
|
uint8_t r, g, b, a;
|
2022-03-21 21:51:23 -04:00
|
|
|
} Color_RGBA8;
|
|
|
|
|
|
|
|
// only use when necessary for alignment purposes
|
|
|
|
typedef union {
|
|
|
|
struct {
|
2022-07-27 17:50:56 -04:00
|
|
|
#ifdef IS_BIGENDIAN
|
2022-07-31 14:50:28 -04:00
|
|
|
uint8_t r, g, b, a;
|
2022-07-27 17:50:56 -04:00
|
|
|
#else
|
2022-07-31 14:50:28 -04:00
|
|
|
uint8_t a, b, g, r;
|
2022-07-27 17:50:56 -04:00
|
|
|
#endif
|
2022-03-21 21:51:23 -04:00
|
|
|
};
|
2022-07-25 23:11:45 -04:00
|
|
|
uint32_t rgba;
|
2022-03-21 21:51:23 -04:00
|
|
|
} Color_RGBA8_u32;
|
|
|
|
|
|
|
|
typedef struct {
|
2022-07-25 23:11:45 -04:00
|
|
|
float r, g, b, a;
|
2022-03-21 21:51:23 -04:00
|
|
|
} Color_RGBAf;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
struct {
|
2022-07-25 23:11:45 -04:00
|
|
|
uint16_t r : 5;
|
|
|
|
uint16_t g : 5;
|
|
|
|
uint16_t b : 5;
|
|
|
|
uint16_t a : 1;
|
2022-03-21 21:51:23 -04:00
|
|
|
};
|
2022-07-25 23:11:45 -04:00
|
|
|
uint16_t rgba;
|
2022-03-21 21:51:23 -04:00
|
|
|
} Color_RGBA16;
|
|
|
|
|
2022-05-31 00:59:35 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2022-03-21 21:51:23 -04:00
|
|
|
#endif
|