ColorUtils
#include <colorutils.h>
Public Types | |
enum | Brightness { Dark , Light } |
Public Types inherited from QObject | |
typedef | QObjectList |
Public Member Functions | |
ColorUtils (QObject *parent=nullptr) | |
Q_INVOKABLE QColor | adjustColor (const QColor &color, const QJSValue &adjustments) |
Q_INVOKABLE QColor | alphaBlend (const QColor &foreground, const QColor &background) |
Q_INVOKABLE ColorUtils::Brightness | brightnessForColor (const QColor &color) |
Q_INVOKABLE qreal | grayForColor (const QColor &color) |
Q_INVOKABLE QColor | linearInterpolation (const QColor &one, const QColor &two, double balance) |
Q_INVOKABLE QColor | scaleColor (const QColor &color, const QJSValue &adjustments) |
Q_INVOKABLE QColor | tintWithAlpha (const QColor &targetColor, const QColor &tintColor, double alpha) |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Static Public Member Functions | |
static Q_INVOKABLE qreal | chroma (const QColor &color) |
static ColorUtils::LabColor | colorToLab (const QColor &color) |
static ColorUtils::XYZColor | colorToXYZ (const QColor &color) |
static qreal | luminance (const QColor &color) |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Additional Inherited Members | |
Properties inherited from QObject | |
objectName | |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Detailed Description
Utilities for processing items to obtain colors and information useful for UIs that need to adjust to variable elements.
Definition at line 18 of file colorutils.h.
Member Enumeration Documentation
◆ Brightness
Describes the contrast of an item.
Enumerator | |
---|---|
Dark | The item is dark and requires a light foreground color to achieve readable contrast. |
Light | The item is light and requires a dark foreground color to achieve readable contrast. |
Definition at line 27 of file colorutils.h.
Constructor & Destructor Documentation
◆ ColorUtils()
|
explicit |
Definition at line 14 of file colorutils.cpp.
Member Function Documentation
◆ adjustColor()
Increases or decreases the properties of color
by fixed amounts.
- Parameters
-
color The color to adjust. adjustments The adjustments to apply to the color.
- Note
value
andlightness
are aliases for the same value.
- Warning
- It is an error to adjust both RGB and HSL properties.
- Since
- 5.69
- org.kde.kirigami 2.12
Definition at line 134 of file colorutils.cpp.
◆ alphaBlend()
Returns the result of overlaying the foreground color on the background color.
- Parameters
-
foreground The color to overlay on the background. background The color to overlay the foreground on.
- Since
- 5.69
- org.kde.kirigami 2.12
Definition at line 33 of file colorutils.cpp.
◆ brightnessForColor()
ColorUtils::Brightness ColorUtils::brightnessForColor | ( | const QColor & | color | ) |
Returns whether a color is bright or dark.
- Since
- 5.69
- org.kde.kirigami 2.12
Definition at line 19 of file colorutils.cpp.
◆ chroma()
|
static |
Returns the CIELAB chroma of the given color.
CIELAB chroma may give a better quantification of how vibrant a color is compared to HSV saturation.
Definition at line 301 of file colorutils.cpp.
◆ colorToLab()
|
static |
Definition at line 271 of file colorutils.cpp.
◆ colorToXYZ()
|
static |
Definition at line 244 of file colorutils.cpp.
◆ grayForColor()
qreal ColorUtils::grayForColor | ( | const QColor & | color | ) |
Same Algorithm as brightnessForColor but returns a 0 to 1 value for an estimate of the equivalent gray light value (luma).
0 as full black, 1 as full white and 0.5 equivalent to a 50% gray.
- Since
- 5.81
- org.kde.kirigami 2.16
Definition at line 28 of file colorutils.cpp.
◆ linearInterpolation()
Returns a linearly interpolated color between color one and color two.
- Parameters
-
one The color to linearly interpolate from. two The color to linearly interpolate to. balance The balance between the two colors. 0.0 will return the first color, 1.0 will return the second color. Values beyond these bounds are valid, and will result in extrapolation.
- Since
- 5.69
- org.kde.kirigami 2.12
Definition at line 59 of file colorutils.cpp.
◆ luminance()
|
static |
Definition at line 309 of file colorutils.cpp.
◆ scaleColor()
Smoothly scales colors.
- Parameters
-
color The color to adjust. adjustments The adjustments to apply to the color. Each value must be between -100.0
and100.0
. This indicates how far the property should be scaled from its original to the maximum if positive or to the minimum if negative.
- Note
value
andlightness
are aliases for the same value.
- Warning
- It is an error to scale both RGB and HSL properties.
- Since
- 5.69
- org.kde.kirigami 2.12
Definition at line 180 of file colorutils.cpp.
◆ tintWithAlpha()
QColor ColorUtils::tintWithAlpha | ( | const QColor & | targetColor, |
const QColor & | tintColor, | ||
double | alpha ) |
Tint a color using a separate alpha value.
This does the same as Qt.tint() except that rather than using the tint color's alpha value, it uses a separate value that gets multiplied with the tint color's alpha. This avoids needing to create a new color just to adjust an alpha value.
- Parameters
-
targetColor The color to tint. tintColor The color to tint with. alpha The amount of tinting to apply.
- Returns
- The tinted color.
- See also
- Qt.tint()
Definition at line 227 of file colorutils.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.