Clutter Engine 0.0.1
Loading...
Searching...
No Matches
Color Struct Reference

Represents a color with red, green, blue, and alpha components. More...

#include <Color.h>

Public Member Functions

 Color ()
 Default constructor. Initializes all components to zero.
 
 Color (float pR, float pG, float pB, float pA=0)
 Constructs a color with the specified components.
 
void operator+= (Color right)
 Adds the right color to the left color.
 
void operator-= (Color right)
 Subtracts the right color from the left color.
 
void operator*= (Color right)
 Multiplies the left color by the right color.
 
void operator/= (Color right)
 Divides the left color by the right color.
 
void operator= (Color right)
 Assigns the right color to the left color.
 
void clamp (float minValue, float maxValue)
 Clamps the color values between the min and max values.
 
Vector3 rbg ()
 Returns the RGB components as a Vector3.
 
std::string ToString ()
 Returns a string representation of the color.
 

Public Attributes

float r = 0
 The red component of the color.
 
float g = 0
 The green component of the color.
 
float b = 0
 The blue component of the color.
 
float a = 0
 The alpha component of the color.
 

Static Public Attributes

static const Color Black = Color(0.0f, 0.0f, 0.0f, 1.0f)
 A color with all components set to zero.
 
static const Color White = Color(1.0f, 1.0f, 1.0f, 1.0f)
 A color with all components set to one.
 
static const Color Red = Color(1.0f, 0.0f, 0.0f, 1.0f)
 A color with the red component set to one.
 
static const Color Green = Color(0.0f, 1.0f, 0.0f, 1.0f)
 A color with the green component set to one.
 
static const Color Blue = Color(0.0f, 0.0f, 1.0f, 1.0f)
 A color with the blue component set to one.
 
static const Color Yellow = Color(1.0f, 1.0f, 0.0f, 1.0f)
 A color with the red and green components set to one.
 
static const Color Cyan = Color(0.0f, 1.0f, 1.0f, 1.0f)
 A color with the green and blue components set to one.
 
static const Color Magenta = Color(1.0f, 0.0f, 1.0f, 1.0f)
 A color with the red and blue components set to one.
 
static const Color Orange = Color(1.0f, 0.5f, 0.0f, 1.0f)
 A color with the red and green components set to one and the blue component set to zero.
 
static const Color Purple = Color(0.5f, 0.0f, 1.0f, 1.0f)
 A color with the red and blue components set to one and the green component set to zero.
 
static const Color Pink = Color(1.0f, 0.0f, 0.5f, 1.0f)
 A color with the red and blue components set to one and the green component set to zero.
 
static const Color Brown = Color(0.5f, 0.25f, 0.0f, 1.0f)
 A color with the red and green components set to one and the blue component set to zero.
 
static const Color Grey = Color(0.5f, 0.5f, 0.5f, 1.0f)
 A color with all components set to 0.5.
 
static const Color Dark_grey = Color(0.25f, 0.25f, 0.25f, 1.0f)
 A color with all components set to 0.25.
 
static const Color Light_grey = Color(0.75f, 0.75f, 0.75f, 1.0f)
 A color with all components set to 0.75.
 
static const Color Teal = Color(0.0f, 0.5f, 0.5f, 1.0f)
 A color with the green and blue components set to 0.5 and the red component set to zero.
 
static const Color Lime = Color(0.5f, 1.0f, 0.5f, 1.0f)
 A color with the red and green components set to 0.5 and the blue component set to zero.
 
static const Color Maroon = Color(0.5f, 0.0f, 0.0f, 1.0f)
 A color with the red component set to 0.5 and the green and blue components set to zero.
 
static const Color Navy = Color(0.0f, 0.0f, 0.5f, 1.0f)
 A color with the blue component set to 0.5 and the red and green components set to zero.
 
static const Color Olive = Color(0.5f, 0.5f, 0.0f, 1.0f)
 A color with the red and green components set to 0.5 and the blue component set to zero.
 
static const Color Silver = Color(0.75f, 0.75f, 0.75f, 1.0f)
 A color with all components set to 0.75.
 
static const Color Gold = Color(1.0f, 0.85f, 0.0f, 1.0f)
 A color with the red component set to 1 and the green and blue components set to 0.85.
 

Detailed Description

Represents a color with red, green, blue, and alpha components.

Constructor & Destructor Documentation

◆ Color()

Color::Color ( float pR,
float pG,
float pB,
float pA = 0 )
inline

Constructs a color with the specified components.

Parameters
pRRed component.
pGGreen component.
pBBlue component.
pAAlpha component (default is 0).

Member Function Documentation

◆ clamp()

void Color::clamp ( float minValue,
float maxValue )
inline

Clamps the color values between the min and max values.

Parameters
minValueThe minimum value.
maxValueThe maximum value.

◆ operator*=()

void Color::operator*= ( Color right)
inline

Multiplies the left color by the right color.

Parameters
rightThe color to multiply by.

◆ operator+=()

void Color::operator+= ( Color right)
inline

Adds the right color to the left color.

Parameters
rightThe color to add.

◆ operator-=()

void Color::operator-= ( Color right)
inline

Subtracts the right color from the left color.

Parameters
rightThe color to subtract.

◆ operator/=()

void Color::operator/= ( Color right)
inline

Divides the left color by the right color.

Parameters
rightThe color to divide by.

◆ operator=()

void Color::operator= ( Color right)
inline

Assigns the right color to the left color.

Parameters
rightThe color to assign.

◆ rbg()

Vector3 Color::rbg ( )
inline

Returns the RGB components as a Vector3.

Returns
Vector3 containing the r, g, b components.

◆ ToString()

std::string Color::ToString ( )
inline

Returns a string representation of the color.

Returns
String in the format "R : <r> , G : <g> , B : <b> , A : <a>"

The documentation for this struct was generated from the following files: