Perceptual Color

lchdouble.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef LCHDOUBLE_H
5#define LCHDOUBLE_H
6
7#include "importexport.h"
8#include <qdebug.h>
9#include <qmetatype.h>
10
11namespace PerceptualColor
12{
13/** @brief A LCH color (Oklch, CielchD50, CielchD65…)
14 *
15 * Storage of floating point LCH values with <tt>double</tt> precision.
16 *
17 * The data is not default-initialized; it is undefined when the object
18 * is created.
19 *
20 * Example:
21 * @snippet testlchdouble.cpp Use LchDouble
22 *
23 * More details about the valid range: @ref lchrange
24 *
25 * This class intentionally does not provide the operators <em>equal
26 * to</em> (<tt>operator==</tt>) and <em>not equal to</em>
27 * (<tt>operator!=</tt>). As LCH colors are polar coordinates,
28 * there are various valid representations of the same angle.
29 * And h is even meaningless when C is zero; on the other hand,
30 * there might nevertheless be an interest in preserving h. And
31 * invalid values with L=200 or L=300: Should they be equal because
32 * both are invalid? Or are they different? The answer to all
33 * these questions depends on your use case. To avoid confusion,
34 * no comparison operators are provided by this class. See also
35 * @ref hasSameCoordinates.
36 *
37 * This type is declared as type to Qt’s type system via
38 * <tt>Q_DECLARE_METATYPE</tt>. Depending on your use case (for
39 * example if you want to use for <em>queued</em> signal-slot connections),
40 * you might consider calling <tt>qRegisterMetaType()</tt> for
41 * this type, once you have a QApplication object.
42 *
43 * This data type can be passed to QDebug thanks to
44 * @ref operator<<(QDebug dbg, const PerceptualColor::LchDouble &value)
45 *
46 * @internal
47 *
48 * @todo Would it make sense to normalize the hue (1° instead
49 * of 361°, and only non-negative radii)? */
51public:
52 /** @brief Lightness, mesured in percent.
53 *
54 * The valid range is <tt>[0, 100]</tt>. */
55 double l;
56 /** @brief Chroma.
57 *
58 * <tt>0</tt> means no chroma (grayscale). The maximum value depends on
59 * the gamut. For sRGB for example it’s a given value, but other gamuts
60 * can be bigger, but the practical limit is the gamut of the
61 * @ref lchrange "human perception", beyond which a
62 * Chroma value does not make sense. */
63 double c;
64 /** @brief Hue, measured in degree.
65 *
66 * The valid range is <tt>[0, 360[</tt>. */
67 double h;
68 [[nodiscard]] bool hasSameCoordinates(const LchDouble &other) const;
69};
70
72
73} // namespace PerceptualColor
74
75Q_DECLARE_METATYPE(PerceptualColor::LchDouble)
76
77#endif // LCHDOUBLE_H
This file provides support for C++ symbol import and export.
#define PERCEPTUALCOLOR_IMPORTEXPORT
A macro that either exports dynamic library symbols or imports dynamic library symbols or does nothin...
The namespace of this library.
A LCH color (Oklch, CielchD50, CielchD65…)
Definition lchdouble.h:50
double l
Lightness, mesured in percent.
Definition lchdouble.h:55
double h
Hue, measured in degree.
Definition lchdouble.h:67
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:47:51 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.