35 lines
772 B
C
35 lines
772 B
C
|
#pragma once
|
||
|
#include <luna/Types.h>
|
||
|
|
||
|
namespace ui
|
||
|
{
|
||
|
/**
|
||
|
* @brief A 32-bit RGBA color.
|
||
|
*/
|
||
|
struct Color
|
||
|
{
|
||
|
union {
|
||
|
u32 raw;
|
||
|
u8 colors[4];
|
||
|
};
|
||
|
|
||
|
static constexpr Color from_u32(u32 raw)
|
||
|
{
|
||
|
return Color { .raw = raw };
|
||
|
}
|
||
|
|
||
|
static constexpr Color from_rgba(u8 red, u8 green, u8 blue, u8 alpha)
|
||
|
{
|
||
|
return Color { .colors = { blue, green, red, alpha } };
|
||
|
}
|
||
|
|
||
|
static constexpr Color from_rgb(u8 red, u8 green, u8 blue)
|
||
|
{
|
||
|
return from_rgba(red, green, blue, 0xff);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
static constexpr Color WHITE = Color::from_rgb(0xff, 0xff, 0xff);
|
||
|
static constexpr Color BLACK = Color::from_rgb(0x00, 0x00, 0x00);
|
||
|
};
|