27 explicit Color(
const float r = 0.0f,
const float g = 0.0f,
const float b = 0.0f,
const float a = 1.0f) :
r(
r),
g(
g),
b(
b),
a(
a) {}
33 explicit Color(
const std::vector<float>& arr);
40 Color(
const float* arr,
size_t size);
129 Color&
fromArray(
const std::vector<float>& arr,
size_t offset = 0);
139 Color&
fromArray(
const float* arr,
size_t size,
size_t offset = 0);
149 [[nodiscard]] std::string
toString(
bool alpha =
false,
bool asArray =
false)
const;
159 [[nodiscard]] std::vector<float>
toArray(std::vector<float> arr = {},
size_t offset = 0,
bool alpha =
true)
const;
169 void toArray(
float* arr,
size_t size,
size_t offset = 0,
bool alpha =
true)
const;
190 static std::array<uint8_t, 3> intToBytes24(uint32_t i);
197 static std::array<uint8_t, 4> intToBytes32(uint32_t i);
206 static float clamp(
float value,
float min,
float max);
RGBA color with floating-point components in [0, 1].
Color(const float r=0.0f, const float g=0.0f, const float b=0.0f, const float a=1.0f)
Color & lerp(const Color &lhs, const Color &rhs, float alpha)
std::string toString(bool alpha=false, bool asArray=false) const
static const Color YELLOW
Color & mulScalar(float scalar)
Color(const Color &other)=default
static const Color MAGENTA
Color & copy(const Color &rhs)
bool operator!=(const Color &other) const
bool operator==(const Color &other) const
bool equals(const Color &rhs) const
Color & gamma(const Color *src=nullptr)
std::vector< float > toArray(std::vector< float > arr={}, size_t offset=0, bool alpha=true) const
Color & linear(const Color *src=nullptr)
Color & operator=(const Color &other)=default
Color & fromString(const std::string &hex)
Color & fromArray(const std::vector< float > &arr, size_t offset=0)
Color & set(float r, float g, float b, float a=1.0f)