|
|
|
@ -62,24 +62,24 @@ typedef uint32_t gl_color32_t;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Extracts red component from gl_color16_t and converts it to 8-bit value
|
|
|
|
|
#define gl_color16_to_r(c) ((((c) & 0xF800) >> 8) | (((c) & 0xF800) >> 13))
|
|
|
|
|
#define gl_color16_to_r(c) ((((c)&0xF800) >> 8) | (((c)&0xF800) >> 13))
|
|
|
|
|
// Extracts green component from gl_color16_t and converts it to 8-bit value
|
|
|
|
|
#define gl_color16_to_g(c) ((((c) & 0x07E0) >> 3) | (((c) & 0x07E0) >> 9))
|
|
|
|
|
#define gl_color16_to_g(c) ((((c)&0x07E0) >> 3) | (((c)&0x07E0) >> 9))
|
|
|
|
|
// Extracts blue component from gl_color16_t and converts it to 8-bit value
|
|
|
|
|
#define gl_color16_to_b(c) ((((c) & 0x001F) << 3) | (((c) & 0x001F) >> 2))
|
|
|
|
|
#define gl_color16_to_b(c) ((((c)&0x001F) << 3) | (((c)&0x001F) >> 2))
|
|
|
|
|
|
|
|
|
|
// Extracts red component from gl_color32_t
|
|
|
|
|
#define gl_color32_to_r(c) (((c) & 0x00FF0000) >> 16)
|
|
|
|
|
#define gl_color32_to_r(c) (((c)&0x00FF0000) >> 16)
|
|
|
|
|
// Extracts green component from gl_color32_t
|
|
|
|
|
#define gl_color32_to_g(c) (((c) & 0x0000FF00) >> 8)
|
|
|
|
|
#define gl_color32_to_g(c) (((c)&0x0000FF00) >> 8)
|
|
|
|
|
// Extracts blue component from gl_color32_t
|
|
|
|
|
#define gl_color32_to_b(c) (((c) & 0x000000FF) >> 0)
|
|
|
|
|
#define gl_color32_to_b(c) (((c)&0x000000FF) >> 0)
|
|
|
|
|
|
|
|
|
|
// 4-bit linear interpolation between `fg` and `bg`
|
|
|
|
|
#define a4_lerp(fg, bg, alpha) (((fg) * (alpha) + ((bg) * (15 - (alpha)))) / 15)
|
|
|
|
|
// 8-bit linear interpolation between `fg` and `bg`
|
|
|
|
|
#define a8_lerp(fg, bg, alpha) (((fg) * (alpha) + ((bg) * (255 - (alpha)))) / 255)
|
|
|
|
|
|
|
|
|
|
#define a8_lerp(fg, bg, alpha) \
|
|
|
|
|
(((fg) * (alpha) + ((bg) * (255 - (alpha)))) / 255)
|
|
|
|
|
|
|
|
|
|
// Constructs a 16-bit color from the given red (r),
|
|
|
|
|
// green (g), and blue (b) values in the range 0..255
|
|
|
|
|