Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickcolor.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qquickcolor_p.h"
5
7
9 QObject(parent)
10{
11}
12
14{
15 const auto rgbColor = color.toRgb();
16 return QColor(rgbColor.red(), rgbColor.green(), rgbColor.blue(),
17 int(qreal(255) * qBound(qreal(0), opacity, qreal(1))));
18}
19
20QColor QQuickColor::blend(const QColor &a, const QColor &b, qreal factor) const
21{
22 if (factor <= 0.0)
23 return a;
24 if (factor >= 1.0)
25 return b;
26
27 const auto rgbA = a.toRgb();
28 const auto rgbB = b.toRgb();
30 color.setRedF(rgbA.redF() * (1.0 - factor) + rgbB.redF() * factor);
31 color.setGreenF(rgbA.greenF() * (1.0 - factor) + rgbB.greenF() * factor);
32 color.setBlueF(rgbA.blueF() * (1.0 - factor) + rgbB.blueF() * factor);
33 return color;
34}
35
37
38#include "moc_qquickcolor_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
void setRedF(float red)
Sets the red color component of this color to red.
Definition qcolor.cpp:1628
QColor toRgb() const noexcept
Create and returns an RGB QColor based on this color.
Definition qcolor.cpp:2035
\inmodule QtCore
Definition qobject.h:103
Q_INVOKABLE QColor transparent(const QColor &color, qreal opacity) const
Q_INVOKABLE QColor blend(const QColor &a, const QColor &b, qreal factor) const
QQuickColor(QObject *parent=nullptr)
Combined button and popup list for selecting options.
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint color
[2]
double qreal
Definition qtypes.h:187