Union::Color Class
class Union::ColorA class that represents a color that can be provided from different sources. More...
| Header: | #include <Color> |
| CMake: | find_package(Union REQUIRED)target_link_libraries(mytarget PRIVATE Union::Union) |
Public Functions
| Color() | |
| uint8_t | alpha() const |
| uint8_t | blue() const |
| uint8_t | green() const |
| bool | isValid() const |
| uint8_t | red() const |
| QColor | toQColor() const |
| Union::Color | toRgba() const |
| QString | toString() const |
| Union::ColorData::Type | type() const |
Static Public Members
| Union::Color | add(const Union::Color &color, const Union::Color &other) |
| Union::Color | custom(const QString &source, const QStringList &arguments) |
| Union::Color | mix(const Union::Color &first, const Union::Color &second, qreal amount) |
| Union::Color | multiply(const Union::Color &color, const Union::Color &other) |
| Union::Color | rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) |
| Union::Color | set(const Union::Color &color, std::optional<uint8_t> r, std::optional<uint8_t> g, std::optional<uint8_t> b, std::optional<uint8_t> a) |
| Union::Color | subtract(const Union::Color &color, const Union::Color &other) |
Detailed Description
The main purpose of this class is to store information about a color without needing to resolve said color to an actual concrete RGBA value. This allows input plugins to provide colors that can be cached without having to regenerate the cache if some color changes.
Member Function Documentation
Color::Color()
Constructor.
Constructs an invalid color.
[static] Union::Color Color::add(const Union::Color &color, const Union::Color &other)
Return a new add color.
Add colors represents the addition of color \p other to \p color.
uint8_t Color::alpha() const
Returns the alpha component of this color if this is an RGBA color, otherwise returns 0.
uint8_t Color::blue() const
Returns the blue component of this color if this is an RGBA color, otherwise returns 0.
[static] Union::Color Color::custom(const QString &source, const QStringList &arguments)
Return a new custom color.
\psource is the custom color source, which needs to be the name of a ColorProvider. \p arguments is a list of arguments to supply to the specified ColorProvider.
uint8_t Color::green() const
Returns the green component of this color if this is an RGBA color, otherwise returns 0.
bool Color::isValid() const
Returns if this color has any data.
[static] Union::Color Color::mix(const Union::Color &first, const Union::Color &second, qreal amount)
Return a new mix color.
Mix colors represent the linear interpolation between the colors \p first and \p second with the specified \p amount.
[static] Union::Color Color::multiply(const Union::Color &color, const Union::Color &other)
Return a new multiply color.
Multiply colors represents the multiplication of color \p color by \p other.
uint8_t Color::red() const
Returns the red component of this color if this is an RGBA color, otherwise returns 0.
[static] Union::Color Color::rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
Return a new RGBA color.
[static] Union::Color Color::set(const Union::Color &color, std::optional<uint8_t> r, std::optional<uint8_t> g, std::optional<uint8_t> b, std::optional<uint8_t> a)
Return a new set color.
Set colors represents a color operation where the values of certain components of color \p color are replaced with different values.
[static] Union::Color Color::subtract(const Union::Color &color, const Union::Color &other)
Return a new subtract color.
Subtract colors represents the subtraction of color \p other from \p color.
QColor Color::toQColor() const
Returns this color converted to a QColor.
If this color is not of RGBA type, it is first converted to RGBA before converting to QColor.
Union::Color Color::toRgba() const
Returns this color converted to an RGBA color.
How the exact conversion happens depends on the current color type.
QString Color::toString() const
Returns a string representation of this color.
Union::ColorData::Type Color::type() const
Returns the type of color.