TGUI  0.9-dev

Wrapper for colors. More...

#include <TGUI/Color.hpp>

Public Member Functions

TGUI_CONSTEXPR Color ()
 Creates the object without a color. More...
 
TGUI_CONSTEXPR Color (const sf::Color &color)
 Creates the object from an sf::Color. More...
 
TGUI_CONSTEXPR 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 String &string)
 Creates the object from a string. More...
 
 Color (const char *string)
 Creates the object from a string. More...
 
TGUI_CONSTEXPR bool isSet () const
 Checks if a color was set. More...
 
 operator sf::Color () const
 Converts this object into an sf::Color object. More...
 
TGUI_CONSTEXPR std::uint8_t getRed () const
 Returns the red component of the color. More...
 
TGUI_CONSTEXPR std::uint8_t getGreen () const
 Returns the green component of the color. More...
 
TGUI_CONSTEXPR std::uint8_t getBlue () const
 Returns the blue component of the color. More...
 
TGUI_CONSTEXPR std::uint8_t getAlpha () const
 Returns the alpha component of the color. More...
 
TGUI_CONSTEXPR bool operator== (const Color &rhs) const
 Compares the color with another one.
 
TGUI_CONSTEXPR bool operator!= (const Color &right) const
 Compares the color with another one.
 

Static Public Member Functions

static TGUI_CONSTEXPR Color applyOpacity (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_CONSTEXPR 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_CONSTEXPR tgui::Color::Color ( const sf::Color &  color)
inline

Creates the object from an sf::Color.

Parameters
colorColor to set

◆ Color() [3/5]

TGUI_CONSTEXPR 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 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()

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

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()

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

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()

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

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()

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

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()

TGUI_CONSTEXPR bool tgui::Color::isSet ( ) const
inline

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
inline

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: