Perceptual Color

lchadouble.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef LCHADOUBLE_H
5#define LCHADOUBLE_H
6
7#include "importexport.h"
8#include <qdebug.h>
9#include <qmetatype.h>
10
11namespace PerceptualColor
12{
13/** @brief A LCH color with alpha channel.
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 testlchadouble.cpp Use LchaDouble
22 *
23 * More details about the valid range: @ref lchrange
24 *
25 * @note This class intentionally does not provide the operators
26 * <em>equal 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::LchaDouble &value)
45 *
46 * @internal
47 *
48 * @todo We could normalize @ref LchaDouble values, just like @ref PolarPointF
49 * also does. Performance should not matter for this use case! But: Does
50 * it make sense? */
52public:
53 /** @brief Lightness, mesured in percent.
54 *
55 * The valid range is <tt>[0, 100]</tt>. */
56 double l;
57 /** @brief Chroma.
58 *
59 * <tt>0</tt> means no chroma (grayscale). The maximum value depends on
60 * the gamut. For sRGB for example it’s a given value, but other gamuts
61 * can be bigger, but the practical limit is the gamut of the
62 * @ref lchrange "human perception", beyond which a
63 * Chroma value does not make sense. */
64 double c;
65 /** @brief Hue, measured in degree.
66 *
67 * The valid range is <tt>[0, 360[</tt>. */
68 double h;
69 /** @brief Opacity (alpha channel)
70 *
71 * The valid range is <tt>[0, 1]</tt>. <tt>0</tt> is fully
72 * transparent, <tt>1</tt> is fully opaque. */
73 double a;
74 [[nodiscard]] bool hasSameCoordinates(const LchaDouble &other) const;
75};
76
78
79} // namespace PerceptualColor
80
81Q_DECLARE_METATYPE(PerceptualColor::LchaDouble)
82
83#endif // LCHADOUBLE_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 with alpha channel.
Definition lchadouble.h:51
double a
Opacity (alpha channel)
Definition lchadouble.h:73
double h
Hue, measured in degree.
Definition lchadouble.h:68
double l
Lightness, mesured in percent.
Definition lchadouble.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:48:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.