TGUI  0.8-dev

Wrapper for colors. More...

#include <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 (sf::Uint8 red, sf::Uint8 green, sf::Uint8 blue, sf::Uint8 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...
 
sf::Uint8 getRed () const
 Returns the red component of the color. More...
 
sf::Uint8 getGreen () const
 Returns the green component of the color. More...
 
sf::Uint8 getBlue () const
 Returns the blue component of the color. More...
 
sf::Uint8 getAlpha () const
 Returns the alpha component of the color. More...
 

Static Public Member Functions

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

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

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)

Creates the object from an sf::Color.

Parameters
colorColor to set

§ Color() [3/5]

tgui::Color::Color ( sf::Uint8  red,
sf::Uint8  green,
sf::Uint8  blue,
sf::Uint8  alpha = 255 
)

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

sf::Uint8 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()

sf::Uint8 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()

sf::Uint8 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()

sf::Uint8 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: