Practical Tools for Simple Design
Loading...
Searching...
No Matches
Util::Color Class Reference

A class representing a color. More...

#include <Color.hpp>

Inheritance diagram for Util::Color:

Public Member Functions

 Color (const glm::vec4 &vec)
 
 Color (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 
 Color (glm::vec4 &&vec)
 
 Color (const SDL_Color &color)
 
SDL_Color ToSdlColor () const
 Converts the color to SDL_Color format. More...
 
std::string ToString () const
 Converts the color to a string representation. More...
 

Static Public Member Functions

static Color FromRGB (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 Get Color From RGB Values. More...
 
static Color FromHSL (float h, float s, float l, float a=1.0F)
 Get Color From HSL Values. More...
 
static Color FromHSV (float h, float s, float v, float a=1.0F)
 Get Color From HSV Values. More...
 
static Color FromHex (Uint32 hex)
 Get Color From Hex RGB Value, alpha value is necessary. More...
 
static Color FromHex (const std::string &hex)
 Get Color From Hex RGB String, alpha value is necessary. More...
 
static Color FromName (const Util::Colors &name)
 Get Color From name within Util::Colors. More...
 

Detailed Description

A class representing a color.

This class is an extend of glm::vec4. It provides functionalities to convert from and to SDL_Color format.

Member Function Documentation

◆ FromHex() [1/2]

static Color Util::Color::FromHex ( const std::string &  hex)
static

Get Color From Hex RGB String, alpha value is necessary.

Parameters
hexHex String ("00000000" - "FFFFFFFF")
Returns
Color

◆ FromHex() [2/2]

static Color Util::Color::FromHex ( Uint32  hex)
static

Get Color From Hex RGB Value, alpha value is necessary.

Parameters
hexHex Value (0x00000000 - 0xFFFFFFFF)
Returns
Color

◆ FromHSL()

static Color Util::Color::FromHSL ( float  h,
float  s,
float  l,
float  a = 1.0F 
)
static

Get Color From HSL Values.

Parameters
hHue Value (0-1)
sSaturation Value (0-1)
lLightness Value (0-1)
aAlpha Value (0-1), default is 1.0
Returns
Color

◆ FromHSV()

static Color Util::Color::FromHSV ( float  h,
float  s,
float  v,
float  a = 1.0F 
)
static

Get Color From HSV Values.

Parameters
hHue Value (0-1)
sSaturation Value (0-1)
vValue (0-1)
aAlpha Value (0-1), default is 1.0
Returns
Color

◆ FromName()

static Color Util::Color::FromName ( const Util::Colors name)
static

Get Color From name within Util::Colors.

Parameters
nameColor Name in Util::Colors
Returns
Color
See also
Util::Colors

◆ FromRGB()

static Color Util::Color::FromRGB ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = 255 
)
static

Get Color From RGB Values.

Parameters
rRed Value (0-255)
gGreen Value (0-255)
bBlue Value (0-255)
aAlpha Value (0-255), default is 255
Returns
Color

◆ ToSdlColor()

SDL_Color Util::Color::ToSdlColor ( ) const
inline

Converts the color to SDL_Color format.

Returns
The color in SDL_Color format.

◆ ToString()

std::string Util::Color::ToString ( ) const
inline

Converts the color to a string representation.

This method returns a string representation of the color in the format "Color(r,g,b,a)". The values r, g, b, and a represent the red, green, blue, and alpha components of the color, respectively.

Returns
A string representation of the color.

The documentation for this class was generated from the following file: