TGUI  0.8.1

Wrapper for colors. More...

#include <TGUI/Color.hpp>

Public Member Functions

 Color ()
 Creates the object without a color. More...
 
 Color (const sf::Color &color)
 Creates the object from an sf::Color. More...
 
 Color (std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha=255)
 Creates the object from an the RGB or RGBA values. More...
 
 Color (const std::string &string)
 Creates the object from a string. More...
 
 Color (const char *string)
 Creates the object from a string. More...
 
bool isSet () const
 Checks if a color was set. More...
 
 operator sf::Color () const
 Converts this object into an sf::Color object. More...
 
std::uint8_t getRed () const
 Returns the red component of the color. More...
 
std::uint8_t getGreen () const
 Returns the green component of the color. More...
 
std::uint8_t getBlue () const
 Returns the blue component of the color. More...
 
std::uint8_t getAlpha () const
 Returns the alpha component of the color. More...
 
bool operator== (const Color &right) const
 Compares the color with another one.
 
bool operator!= (const Color &right) const
 Compares the color with another one.
 
bool operator== (const sf::Color &right) const
 Compares the color with another one.
 
bool operator!= (const sf::Color &right) const
 Compares the color with another one.
 

Static Public Member Functions

static Color calcColorOpacity (const Color &color, float alpha)
 Returns the color with its alpha channel multiplied with the alpha parameter.
 

Static Public Attributes

static const Color Black
 Black predefined color.
 
static const Color White
 White predefined color.
 
static const Color Red
 Red predefined color.
 
static const Color Green
 Green predefined color.
 
static const Color Blue
 Blue predefined color.
 
static const Color Yellow
 Yellow predefined color.
 
static const Color Magenta
 Magenta predefined color.
 
static const Color Cyan
 Cyan predefined color.
 
static const Color Transparent
 Transparent (black) predefined color.
 

Detailed Description

Wrapper for colors.

The class is used for 2 purposes:

  • Implicit converter for parameters. A function taking a Color as parameter can be given an sf::Color, RGB values or even a serialized string as argument.
  • Storing no color at all. Some colors may be optionally set and can thus remain unspecified.

Constructor & Destructor Documentation

◆ Color() [1/5]

tgui::Color::Color ( )
inline

Creates the object without a color.

The isSet() function will return false when the object was created using this constructor.

◆ Color() [2/5]

tgui::Color::Color ( const sf::Color &  color)
inline

Creates the object from an sf::Color.

Parameters
colorColor to set

◆ Color() [3/5]

tgui::Color::Color ( std::uint8_t  red,
std::uint8_t  green,
std::uint8_t  blue,
std::uint8_t  alpha = 255 
)
inline

Creates the object from an the RGB or RGBA values.

Parameters
redRed component
greenGreen component
blueBlue component
alphaAlpha component

◆ Color() [4/5]

tgui::Color::Color ( const std::string &  string)

Creates the object from a string.

Parameters
stringString to be deserialized as color

The Deserializer class is used to convert the string into a color.

◆ Color() [5/5]

tgui::Color::Color ( const char *  string)

Creates the object from a string.

Parameters
stringString to be deserialized as color

The Deserializer class is used to convert the string into a color.

Member Function Documentation

◆ getAlpha()

std::uint8_t tgui::Color::getAlpha ( ) const

Returns the alpha component of the color.

Returns
Alpha component of the stored color or the one from the default color is no color was set

◆ getBlue()

std::uint8_t tgui::Color::getBlue ( ) const

Returns the blue component of the color.

Returns
Blue component of the stored color or the one from the default color is no color was set

◆ getGreen()

std::uint8_t tgui::Color::getGreen ( ) const

Returns the green component of the color.

Returns
Green component of the stored color or the one from the default color is no color was set

◆ getRed()

std::uint8_t tgui::Color::getRed ( ) const

Returns the red component of the color.

Returns
Red component of the stored color or the one from the default color is no color was set

◆ isSet()

bool tgui::Color::isSet ( ) const

Checks if a color was set.

Returns
True if a color was passed to the constructor, false when the default constructor was used

◆ operator sf::Color()

tgui::Color::operator sf::Color ( ) const

Converts this object into an sf::Color object.

Returns
The color stored in this object, or the default color if no color was set

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