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
qquickcolordialogutils.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 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
5
6std::pair<qreal, qreal> getSaturationAndValue(qreal saturation, qreal lightness)
7{
8 const qreal v = lightness + saturation * qMin(lightness, 1 - lightness);
9 if (v == .0)
10 return { .0, .0 };
11 const qreal s = 2 * (1 - lightness / v);
12 return { s, v };
13}
14
15std::pair<qreal, qreal> getSaturationAndLightness(qreal saturation, qreal value)
16{
17 const qreal l = value * (1 - saturation / 2);
18 if (l == .0)
19 return { .0, .0 };
20 if (l == 1 && value == 1)
21 return { saturation, l };
22 const qreal s = (value - l) / qMin(l, 1 - l);
23 return { s, l };
24}
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
GLsizei const GLfloat * v
[13]
GLdouble s
[6]
Definition qopenglext.h:235
std::pair< qreal, qreal > getSaturationAndLightness(qreal saturation, qreal value)
std::pair< qreal, qreal > getSaturationAndValue(qreal saturation, qreal lightness)
double qreal
Definition qtypes.h:187