29#include <TGUI/String.hpp>
30#include <TGUI/Vertex.hpp>
35#if TGUI_HAS_BACKEND_SFML
36 #include <SFML/Graphics/Color.hpp>
46 TGUI_API Color constructColorFromString(String
string);
58#if TGUI_COMPILED_WITH_CPP_VER >= 17
91#if TGUI_HAS_BACKEND_SFML
97 TGUI_CONSTEXPR
Color(
const sf::Color& color) :
115 TGUI_CONSTEXPR
Color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 255) :
133 Color{priv::constructColorFromString(string)}
161#if TGUI_HAS_BACKEND_SFML
167 operator sf::Color()
const
169 return sf::Color(m_red, m_green, m_blue, m_alpha);
189 TGUI_CONSTEXPR std::uint8_t
getRed()
const
233 return (m_isSet == rhs.m_isSet)
234 && (m_red == rhs.m_red)
235 && (m_green == rhs.m_green)
236 && (m_blue == rhs.m_blue)
237 && (m_alpha == rhs.m_alpha);
246 return !(*
this == right);
263#ifndef TGUI_REMOVE_DEPRECATED_CODE
264 TGUI_DEPRECATED(
"Use colorNamesMap instead") static const std::map<
String,
Color> colorMap;
266 static const std::array<std::pair<StringView, Color>, 9> colorNamesMap;
274 std::uint8_t m_green;
276 std::uint8_t m_alpha;
297 TGUI_API
Color constructColorFromString(
String string);
302#if TGUI_COMPILED_WITH_CPP_VER >= 17
304 inline constexpr const Color
Color::White {255, 255, 255};
305 inline constexpr const Color
Color::Red {255, 0, 0};
307 inline constexpr const Color
Color::Blue { 0, 0, 255};
310 inline constexpr const Color
Color::Cyan { 0, 255, 255};
313 inline constexpr const std::array<std::pair<StringView, Color>, 9> Color::colorNamesMap
Wrapper for colors.
Definition Color.hpp:63
TGUI_CONSTEXPR Color(const sf::Color &color)
Creates the object from an sf::Color.
Definition Color.hpp:97
static const Color Transparent
Transparent (black) predefined color.
Definition Color.hpp:261
TGUI_CONSTEXPR std::uint8_t getGreen() const
Returns the green component of the color.
Definition Color.hpp:200
static TGUI_CONSTEXPR Color applyOpacity(const Color &color, float alpha)
Returns the color with its alpha channel multiplied with the alpha parameter.
Definition Color.hpp:69
TGUI_CONSTEXPR std::uint8_t getAlpha() const
Returns the alpha component of the color.
Definition Color.hpp:222
static const Color Black
Black predefined color.
Definition Color.hpp:253
static const Color Green
Green predefined color.
Definition Color.hpp:256
TGUI_CONSTEXPR bool operator==(const Color &rhs) const
Compares the color with another one.
Definition Color.hpp:231
TGUI_CONSTEXPR bool operator!=(const Color &right) const
Compares the color with another one.
Definition Color.hpp:244
static const Color White
White predefined color.
Definition Color.hpp:254
TGUI_CONSTEXPR Color()
Creates the object without a color.
Definition Color.hpp:82
Color(const char *string)
Creates the object from a string.
Definition Color.hpp:145
TGUI_CONSTEXPR std::uint8_t getRed() const
Returns the red component of the color.
Definition Color.hpp:189
static const Color Cyan
Cyan predefined color.
Definition Color.hpp:260
static const Color Magenta
Magenta predefined color.
Definition Color.hpp:259
TGUI_CONSTEXPR std::uint8_t getBlue() const
Returns the blue component of the color.
Definition Color.hpp:211
static const Color Yellow
Yellow predefined color.
Definition Color.hpp:258
static const Color Red
Red predefined color.
Definition Color.hpp:255
static const Color Blue
Blue predefined color.
Definition Color.hpp:257
TGUI_CONSTEXPR bool isSet() const
Checks if a color was set.
Definition Color.hpp:156
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.
Definition Color.hpp:115
Color(const String &string)
Creates the object from a string.
Definition Color.hpp:132
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36