2023-08-03 10:19:45 +00:00
|
|
|
#pragma once
|
|
|
|
#include <luna/Types.h>
|
|
|
|
|
|
|
|
namespace ui
|
|
|
|
{
|
|
|
|
/**
|
2023-08-03 15:38:49 +00:00
|
|
|
* @brief A 32-bit ARGB color.
|
2023-08-03 10:19:45 +00:00
|
|
|
*/
|
|
|
|
struct Color
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
u32 raw;
|
|
|
|
u8 colors[4];
|
|
|
|
};
|
|
|
|
|
2023-08-03 15:38:49 +00:00
|
|
|
/**
|
|
|
|
* @brief Construct a new color from a 32-bit ARGB integer.
|
|
|
|
*
|
|
|
|
* @param raw The integer representing the color.
|
|
|
|
* @return constexpr Color The new color.
|
|
|
|
*/
|
2023-08-03 10:19:45 +00:00
|
|
|
static constexpr Color from_u32(u32 raw)
|
|
|
|
{
|
|
|
|
return Color { .raw = raw };
|
|
|
|
}
|
|
|
|
|
2023-08-03 15:38:49 +00:00
|
|
|
/**
|
|
|
|
* @brief Construct a new color from its separate RGBA values (from 0 to 255).
|
|
|
|
*
|
|
|
|
* @param red The red value.
|
|
|
|
* @param green The green value.
|
|
|
|
* @param blue The blue value.
|
|
|
|
* @param alpha The alpha value.
|
|
|
|
* @return constexpr Color The new color.
|
|
|
|
*/
|
2023-08-03 10:19:45 +00:00
|
|
|
static constexpr Color from_rgba(u8 red, u8 green, u8 blue, u8 alpha)
|
|
|
|
{
|
|
|
|
return Color { .colors = { blue, green, red, alpha } };
|
|
|
|
}
|
|
|
|
|
2023-08-03 15:38:49 +00:00
|
|
|
/**
|
|
|
|
* @brief Construct a new color from its separate RGB values (from 0 to 255).
|
|
|
|
*
|
|
|
|
* @param red The red value.
|
|
|
|
* @param green The green value.
|
|
|
|
* @param blue The blue value.
|
|
|
|
* @return constexpr Color The new color.
|
|
|
|
*/
|
2023-08-03 10:19:45 +00:00
|
|
|
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);
|
2023-08-03 15:38:49 +00:00
|
|
|
|
|
|
|
static constexpr Color BLUE = Color::from_rgb(0x00, 0x00, 0xff);
|
|
|
|
static constexpr Color GREEN = Color::from_rgb(0x00, 0xff, 0x00);
|
|
|
|
static constexpr Color RED = Color::from_rgb(0xff, 0x00, 0x00);
|
|
|
|
|
|
|
|
static constexpr Color CYAN = Color::from_rgb(0x00, 0xff, 0xff);
|
2023-08-03 10:19:45 +00:00
|
|
|
};
|