Skip to content

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)
ParameterDescription
rRed component.
gGreen component.
bBlue component.

Constructs a Color object from individual RGB components.

Color() constexpr

cpp
vglx::Color::Color(std::span< float > color)
ParameterDescription
colorSpan 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)
ParameterDescription
hexHexadecimal color code.

Constructs a Color object from a hexadecimal value. The hex format is 0xRRGGBB. Each channel is normalized to [0.0, 1.0].

operator*=() Color&

cpp
Color & vglx::Color::operator*=(float n)
ParameterDescription
nScalar value.

Multiplies the color by a scalar in-place.

operator=() Color&

cpp
Color & vglx::Color::operator=(unsigned int hex)
ParameterDescription
hexHexadecimal color code in 0xRRGGBB format.

Assigns a new color from a hexadecimal value.

operator[]() auto &

cpp
auto & vglx::Color::operator[](int i)
ParameterDescription
iIndex (0 for r, 1 for g, 2 for b).

Accesses color components by index.

operator[]() auto &

cpp
auto & vglx::Color::operator[](int i) const
ParameterDescription
iIndex (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)
ParameterDescription
aStart color.
bEnd color.
fInterpolation factor [0, 1].

Linearly interpolates between two vectors.

Released under the MIT License.