23 constexpr Color4f(
float r_,
float g_,
float b_) :
28 constexpr Color4f(
float r_,
float g_,
float b_,
float a_) :
33 operator float *() {
return &
r; }
34 operator const float *()
const {
return &
r; }
62 static const float s_inv255 = 1.0f / 255.0f;
63#define INV255(n) (Uint8(float(n) * s_inv255))
74 constexpr Color4ub(Uint8 r_, Uint8 g_, Uint8 b_) :
79 constexpr Color4ub(Uint8 r_, Uint8 g_, Uint8 b_, Uint8 a_) :
85 r(Uint8(c.
r * 255.f)),
86 g(Uint8(c.
g * 255.f)),
87 b(Uint8(c.
b * 255.f)),
88 a(Uint8(c.
a * 255.f)) {}
90 r((rgba >> 24) & 0xff),
91 g((rgba >> 16) & 0xff),
92 b((rgba >> 8) & 0xff),
100 operator unsigned char *() {
return &
r; }
101 operator const unsigned char *()
const {
return &
r; }
135 out.
r =
static_cast<Uint8
>(
r * (1.0f - factor));
136 out.
g =
static_cast<Uint8
>(
g * (1.0f - factor));
137 out.
b =
static_cast<Uint8
>(
b * (1.0f - factor));
143 out.
r =
static_cast<Uint8
>(
r + (255.0f -
r) * factor);
144 out.
g =
static_cast<Uint8
>(
g + (255.0f -
g) * factor);
145 out.
b =
static_cast<Uint8
>(
b + (255.0f -
b) * factor);
151 out.
a =
static_cast<Uint8
>(factor <= 1.0 ? factor * 255 : uint8_t(factor));
182 r(Uint8(c.
r * 255.f)),
183 g(Uint8(c.
g * 255.f)),
184 b(Uint8(c.
b * 255.f)) {}
186 operator unsigned char *() {
return &
r; }
187 operator const unsigned char *()
const {
return &
r; }
Color4ub Color
Definition Color.h:212
#define INV255(n)
Definition Color.h:63
static const Color3ub BLACK
Definition Color.h:202
static const Color3ub BLUE
Definition Color.h:206
Color3ub & operator*=(const Color3ub &c)
Definition Color.h:188
Color4f ToColor4f() const
Definition Color.h:200
constexpr Color3ub(const Color4f &c)
Definition Color.h:181
Color3ub operator*(const float f) const
Definition Color.h:196
static const Color3ub WHITE
Definition Color.h:203
static const Color3ub STEELBLUE
Definition Color.h:208
Uint8 r
Definition Color.h:168
Uint8 g
Definition Color.h:168
static const Color3ub GREEN
Definition Color.h:205
Color3ub operator+(const Color3ub &c) const
Definition Color.h:195
static const Color3ub YELLOW
Definition Color.h:207
static const Color3ub BLANK
Definition Color.h:209
Color3ub operator*(const Color3ub &c) const
Definition Color.h:197
constexpr Color3ub()
Definition Color.h:169
Color3ub operator/(const float f) const
Definition Color.h:198
static const Color3ub RED
Definition Color.h:204
constexpr Color3ub(Uint8 v_)
Definition Color.h:173
Uint8 b
Definition Color.h:168
constexpr Color3ub(Uint8 r_, Uint8 g_, Uint8 b_)
Definition Color.h:177
void ToLuaTable(lua_State *l)
Definition Color.cpp:42
static const Color4f WHITE
Definition Color.h:51
float GetLuminance() const
Definition Color.cpp:37
float b
Definition Color.h:12
float a
Definition Color.h:12
static const Color4f RED
Definition Color.h:52
static Color4f FromLuaTable(lua_State *l, int idx)
Definition Color.cpp:61
static const Color4f YELLOW
Definition Color.h:55
Color4f & operator*=(const float v)
Definition Color.h:35
static const Color4f BLANK
Definition Color.h:58
float r
Definition Color.h:12
constexpr Color4f(float r_, float g_, float b_, float a_)
Definition Color.h:28
float g
Definition Color.h:12
friend Color4f operator*(const Color4f &c, const float v)
Definition Color.h:43
constexpr Color4f(float r_, float g_, float b_)
Definition Color.h:23
static const Color4f STEELBLUE
Definition Color.h:57
constexpr Color4f()
Definition Color.h:13
constexpr Color4f(float v_)
Definition Color.h:18
static const Color4f GREEN
Definition Color.h:53
static const Color4f BLACK
Definition Color.h:50
static const Color4f BLUE
Definition Color.h:54
static const Color4f GRAY
Definition Color.h:56
Color4ub operator/(const float f) const
Definition Color.h:121
Color4ub Opacity(float factor)
Definition Color.h:148
Color4ub & operator*=(const float f)
Definition Color.h:103
Color4ub operator*(const Color4ub &c) const
Definition Color.h:120
static const Color4ub WHITE
Definition Color.h:156
Color4ub Shade(float factor)
Definition Color.h:132
static const Color4ub YELLOW
Definition Color.h:160
static const Color4ub GRAY
Definition Color.h:161
Color4ub Tint(float factor)
Definition Color.h:140
Color4ub & operator*=(const Color4ub &c)
Definition Color.h:111
friend bool operator!=(const Color4ub &aIn, const Color4ub &bIn)
Definition Color.h:124
constexpr Color4ub()
Definition Color.h:69
Color4f ToColor4f() const
Definition Color.h:126
static const Color4ub RED
Definition Color.h:157
static const Color4ub STEELBLUE
Definition Color.h:162
Uint8 a
Definition Color.h:68
constexpr Color4ub(Uint8 r_, Uint8 g_, Uint8 b_, Uint8 a_)
Definition Color.h:79
static const Color4ub BLACK
Definition Color.h:155
static const Color4ub GREEN
Definition Color.h:158
friend bool operator==(const Color4ub &aIn, const Color4ub &bIn)
Definition Color.h:123
static const Color4ub BLUE
Definition Color.h:159
Color4ub operator*(const float f) const
Definition Color.h:119
static const Color4ub BLANK
Definition Color.h:163
static Color4ub FromLuaTable(lua_State *l, int idx)
Definition Color.cpp:88
Uint8 GetLuminance() const
Definition Color.cpp:106
void ToLuaTable(lua_State *l)
Definition Color.cpp:79
Uint8 b
Definition Color.h:68
constexpr Color4ub(const Color4ub &c, const Uint8 a)
Definition Color.h:94
static const Color4ub PINK
Definition Color.h:164
Uint8 g
Definition Color.h:68
constexpr Color4ub(const Color4f &c)
Definition Color.h:84
Uint8 r
Definition Color.h:68
Color4ub operator+(const Color4ub &c) const
Definition Color.h:102
constexpr Color4ub(Uint8 r_, Uint8 g_, Uint8 b_)
Definition Color.h:74
constexpr Color4ub(const Uint32 rgba)
Definition Color.h:89