Perceptual Color

cielchd50values.h
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4#ifndef CIELCHD50VALUES_H
5#define CIELCHD50VALUES_H
6
7#include "lchdouble.h"
8
9namespace PerceptualColor
10{
11/** @internal
12 *
13 * @brief CIELCH-D50 default values
14 *
15 * The @ref lchrangerationale "range of CIELCh-D50 values" it known.
16 * But what could be useful default values? This struct provides some
17 * proposals. All values are <tt>constexpr</tt>. */
18struct CielchD50Values final {
19public:
20 /** @brief Maximum chroma value as defined in @ref lchrangerationale. */
21 static constexpr int maximumChroma = 255;
22 /** @brief Neutral chroma value
23 *
24 * For chroma, a neutral value of 0 might be a good
25 * choice because it is less likely to make out-of-gamut problems on
26 * any lightness (except maybe extreme white or extreme black). And
27 * it results in an achromatic color and is therefore perceived as
28 * neutral. */
29 static constexpr int neutralChroma = 0;
30 /** @brief Neutral hue value
31 *
32 * For the hue, a default value of 0 might be used by convention. */
33 static constexpr int neutralHue = 0;
34 /** @brief Neutral lightness value
35 *
36 * For the lightness, a neutral value of 50 seems a good choice as it
37 * is half the way in the defined lightness range of <tt>[0, 100]</tt>
38 * (thought not all gamuts offer the hole range of <tt>[0, 100]</tt>). As
39 * it is quite in the middle of the gamut solid, it allows for quite big
40 * values for chroma at different hues without falling out-of-gamut.
41 * Combined with a chroma of 0, it also approximates the color with
42 * the highest possible contrast against the hole surface of the
43 * gamut solid; this is interesting for background colors of
44 * gamut diagrams. */
45 static constexpr int neutralLightness = 50;
46 /** @brief Neutral gray color as Lab value.
47 *
48 * Neutral gray is a good choice for the background, as it is equally
49 * distant from black and white, and also quite distant from any
50 * saturated color.
51 *
52 * @todo Given that this might be used quite often, it could be useful
53 * to provide the corresponding RGB value within @ref RgbColorSpace
54 * as a property, returning a variable that is initialized on first
55 * usage. */
56 static constexpr LchDouble neutralGray{neutralLightness, //
57 neutralChroma, //
58 neutralHue};
59 /** @brief Versatile chroma value in
60 * <a href="http://www.littlecms.com/">LittleCMS</a>’ build-in
61 * sRGB gamut
62 *
63 * Depending on the use case, there might be an alternative to
64 * the neutral gray @ref neutralChroma. For a lightness of 50, this
65 * value is the maximum chroma available at all possible hues within
66 * a usual sRGB gamut.
67 *
68 * @sa @ref neutralChroma
69 *
70 * @todo This value should be removed in favor of using individual
71 * values for each gamut. */
72 static constexpr int srgbVersatileChroma = 32;
73 /** @brief Versatile initial color for widgets in
74 * <a href="http://www.littlecms.com/">LittleCMS</a>’ build-in
75 * sRGB gamut
76 *
77 * This provides a colorful (non-gray) initial color.
78 *
79 * The lightness and the chroma value are somewhere in the middle of
80 * the valid range. In sRGB this is always a valid value pair, even if
81 * the hue changes. Both, lightness and chroma, are linear ranges,
82 * so it seems appropriate to have values somewhere in the middle
83 * as initial color: The widgets will display the handles somewhere
84 * in the middle, which is easier to spot for new users than having
85 * them at the very beginning or the very end.
86 *
87 * The hue range is not linear, but circular – and so are the widgets
88 * displaying him: The handle has the same visibility, wherever he is
89 * and whatever the hue value is. Therefore, we use 0° as default value
90 * which seems to be the natural choice.
91 *
92 * @note An alternative to 0° might be 180°. If the lightness is 50%,
93 * among 0°, 90°, 180° and 270°, it’s 180° that has the lowest possible
94 * maximum chroma. So when choose 180°, with a given chroma, the resulting
95 * color is more vivid and clean than those at 0°, 90° and 270°. */
96 static constexpr LchDouble srgbVersatileInitialColor = {neutralLightness, srgbVersatileChroma, neutralHue};
97
98private:
99 /** @brief Delete the constructor to disallow creating an instance
100 * of this class. */
101 CielchD50Values() = delete;
102};
103
104} // namespace PerceptualColor
105
106#endif // CIELCHD50VALUES_H
The namespace of this library.
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.