Core::Display::Color
Introduction
The Color
class provides a structured way to manage and manipulate color values, especially when integrating with GLM's vector systems.
Usage
Initialization
The Color
structure comes with four floating-point components for representing RGBA values:
struct Color {
float red = 0.0f;
float green = 0.0f;
float blue = 0.0f;
float alpha = 1.0f;
};
By default, the color is initialized as transparent black.
Working with Vectors
Color
can directly interact with glm::vec3
and glm::vec4
, allowing for streamlined assignments:
For glm::vec3
:
x
corresponds tored
y
corresponds togreen
z
corresponds toblue
For glm::vec4
:
x
corresponds tored
y
corresponds togreen
z
corresponds toblue
w
corresponds toalpha
Operators
Color Operators
Assign color values directly from an initializer list:
Color color;
color = {255, 0, 0}; // Set to Red
Vec3 Operators
Directly assign values from a glm::vec3
:
glm::vec3 vec(1.0f, 0.0f, 0.0f);
Color color;
color = vec; // Set color to Red using a glm::vec3
Vec4 Operators
Similarly, you can assign values from a glm::vec4
:
glm::vec4 vec(1.0f, 0.0f, 0.0f, 1.0f);
Color color;
color = vec; // Set color to opaque Red using a glm::vec4
Last updated