ladybird/SharedGraphics/Color.h

41 lines
772 B
C
Raw Normal View History

2018-10-10 14:49:36 +00:00
#pragma once
#include <AK/Types.h>
typedef dword RGBA32;
inline constexpr dword make_rgb(byte r, byte g, byte b)
{
return ((r << 16) | (g << 8) | b);
}
2018-10-10 14:49:36 +00:00
class Color {
public:
enum NamedColor {
Black,
White,
Red,
Green,
Blue,
2019-01-12 03:02:36 +00:00
Yellow,
Magenta,
2018-10-12 21:02:23 +00:00
DarkGray,
MidGray,
LightGray,
};
2018-10-10 14:49:36 +00:00
Color() { }
Color(NamedColor);
Color(byte r, byte g, byte b) : m_value((r << 16) | (g << 8) | b) { }
2019-01-13 00:59:38 +00:00
Color(RGBA32 rgba) : m_value(rgba) { }
2018-10-10 14:49:36 +00:00
int red() const { return (m_value >> 16) & 0xff; }
int green() const { return (m_value >> 8) & 0xff; }
int blue() const { return m_value & 0xff; }
RGBA32 value() const { return m_value; }
2018-10-10 14:49:36 +00:00
private:
RGBA32 m_value { 0 };
2018-10-10 14:49:36 +00:00
};