Perceptual Color

lchadouble.cpp
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4// Own header
5#include "lchadouble.h"
6
7#include <type_traits>
8
9#include <lcms2.h>
10
11/** @internal
12 *
13 * @file
14 *
15 * This file defines some static asserts for the data type
16 * @ref PerceptualColor::LchaDouble. */
17
18namespace PerceptualColor
19{
20// We are using double. Check that we stay compatible with cmsCIELCh
21// which is based on cmsFloat64Number.
22static_assert(std::is_same_v<cmsFloat64Number, double>);
23
24static_assert(sizeof(double) == sizeof(cmsFloat64Number));
25
26static_assert(std::is_trivially_copyable_v<LchaDouble>);
27static_assert(std::is_trivial_v<LchaDouble>);
28
29static_assert(std::is_standard_layout_v<LchaDouble>);
30
31static_assert(std::is_default_constructible_v<LchaDouble>);
32static_assert(std::is_trivially_default_constructible_v<LchaDouble>);
33static_assert(std::is_nothrow_default_constructible_v<LchaDouble>);
34
35static_assert(std::is_copy_constructible_v<LchaDouble>);
36static_assert(std::is_trivially_copy_constructible_v<LchaDouble>);
37static_assert(std::is_nothrow_copy_constructible_v<LchaDouble>);
38
39static_assert(std::is_move_constructible_v<LchaDouble>);
40static_assert(std::is_trivially_move_constructible_v<LchaDouble>);
41static_assert(std::is_nothrow_move_constructible_v<LchaDouble>);
42
43/** @brief Adds QDebug() support for data type
44 * @ref PerceptualColor::LchaDouble
45 *
46 * @param dbg Existing debug object
47 * @param value Value to stream into the debug object
48 * @returns Debug object with value streamed in
49 *
50 * @internal
51 *
52 * @todo This is originally declared in the global namespace instead of
53 * the @ref PerceptualColor namespace, because the supported value was
54 * a <tt>typedef</tt> for a LittleCMS type in the global; when declaring
55 * this function in @ref PerceptualColor namespace, it did not work
56 * in the global namespace. Now, things have changed. But we should write
57 * a unit test for if it works in global namespace! */
58QDebug operator<<(QDebug dbg, const PerceptualColor::LchaDouble &value)
59{
60 dbg.nospace() << "LchaDouble(" << value.l << "% " << value.c << " " << value.h << "° " << value.a << ")";
61 return dbg.maybeSpace();
62}
63
64/** @brief Compares coordinates with another object.
65 *
66 * @param other The object to compare with
67 * @returns <tt>true</tt> if all three coordinates @ref l, @ref c and @ref h
68 * of <em>this</em> object are all equal to the coordinates of <em>other</em>.
69 * <tt>false</tt> otherwise. Note that two objects with equal @ref l and
70 * equal @ref c, but one with h = 5° and the other with h = 365°, are
71 * considered non-equal thought both describe the same point in the
72 * coordinate space. */
74{
75 return ((l == other.l) && (c == other.c) && (h == other.h) && (a == other.a));
76}
77
78} // namespace PerceptualColor
The namespace of this library.
QDebug & maybeSpace()
QDebug & nospace()
A LCH color with alpha channel.
Definition lchadouble.h:51
bool hasSameCoordinates(const LchaDouble &other) const
Compares coordinates with another object.
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 Jul 26 2024 11:50:27 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.