Color
Represents an RGB color with floating-point components.
Properties
b float
cpp
float b { 1.0f }
Blue channel [0.0, 1.0].
g float
cpp
float g { 1.0f }
Green channel [0.0, 1.0].
r float
cpp
float r { 1.0f }
Red channel [0.0, 1.0].
Functions
Color() constexpr
cpp
vglx::Color::Color(float r, float g, float b)
Parameter | Description |
---|---|
r | Red component. |
g | Green component. |
b | Blue component. |
Constructs a Color object from individual RGB components.
Color() constexpr
cpp
vglx::Color::Color(std::span< float > color)
Parameter | Description |
---|---|
color | Span containing red, green, and blue components. |
Constructs a Color object from a span of 3 float values.
Color() constexpr
cpp
vglx::Color::Color(unsigned int hex)
Parameter | Description |
---|---|
hex | Hexadecimal color code. |
Constructs a Color object from a hexadecimal value. The hex format is 0xRRGGBB. Each channel is normalized to [0.0, 1.0].
cpp
Color & vglx::Color::operator*=(float n)
Parameter | Description |
---|---|
n | Scalar value. |
Multiplies the color by a scalar in-place.
cpp
Color & vglx::Color::operator=(unsigned int hex)
Parameter | Description |
---|---|
hex | Hexadecimal color code in 0xRRGGBB format. |
Assigns a new color from a hexadecimal value.
operator[]() auto &
cpp
auto & vglx::Color::operator[](int i)
Parameter | Description |
---|---|
i | Index (0 for r, 1 for g, 2 for b). |
Accesses color components by index.
operator[]() auto &
cpp
auto & vglx::Color::operator[](int i) const
Parameter | Description |
---|---|
i | Index (0 for r, 1 for g, 2 for b). |
Accesses color components by index (const).
Lerp() auto
cpp
auto Lerp(const Color &a, const Color &b, float f)
Parameter | Description |
---|---|
a | Start color. |
b | End color. |
f | Interpolation factor [0, 1]. |
Linearly interpolates between two vectors.