47 constexpr CColor() :
r(-1.f),
g(-1.f),
b(-1.f),
a(1.f) {}
48 constexpr CColor(
float cr,
float cg,
float cb,
float ca) :
r(cr),
g(cg),
b(cb),
a(ca) {}
55 return r >= 0 &&
g >= 0 &&
b >= 0 &&
a >= 0;
64 bool ParseString(
const CStr8& value,
int defaultAlpha = 255);
69 return !(*
this == color);
78 sizeof(
CColor) ==
sizeof(
float) * 4u &&
80 offsetof(
CColor,
g) ==
sizeof(float) &&
81 offsetof(
CColor,
b) ==
sizeof(float) * 2u &&
82 offsetof(
CColor,
a) ==
sizeof(float) * 3u,
83 "CColor should be properly layouted to use AsFloatArray");
84 return std::span<const float, 4>(&
r, 4);
91 static_cast<std::uint8_t
>(
r * 255.f),
92 static_cast<std::uint8_t
>(
g * 255.f),
93 static_cast<std::uint8_t
>(
b * 255.f),
94 static_cast<std::uint8_t
>(
a * 255.f)
void ColorActivateFastImpl()
Detects CPU caps and activates the best possible codepath.
Definition: Color.cpp:81
SColor4ub(* ConvertRGBColorTo4ub)(const RGBColor &src)
Definition: Color.cpp:46
CVector4D RGBAColor
Definition: Color.h:33
CVector3D RGBColor
Definition: Color.h:32
Definition: Vector3D.h:32
Definition: Vector4D.h:30
bool ParseString(const CStr8 &value, int defaultAlpha=255)
Try to parse Value as a color.
Definition: Color.cpp:97
constexpr CColor()
Definition: Color.h:47
constexpr CColor(float cr, float cg, float cb, float ca)
Definition: Color.h:48
bool operator==(const CColor &color) const
Definition: Color.cpp:143
float g
Definition: Color.h:98
bool operator!=(const CColor &color) const
Definition: Color.h:67
float a
Definition: Color.h:98
float b
Definition: Color.h:98
float r
Definition: Color.h:98
std::span< const float, 4 > AsFloatArray() const
Definition: Color.h:73
SColor4ub AsSColor4ub() const
Definition: Color.h:88