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 | custom(const QString &source, const QStringList &arguments) |
Union::Color | mix(const Union::Color &first, const Union::Color &second, qreal amount) |
Union::Color | rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) |
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.
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.
\p
source 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.
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.
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.