Perceptual Color

lchdouble.cpp
1// SPDX-FileCopyrightText: Lukas Sommer <sommerluk@gmail.com>
2// SPDX-License-Identifier: BSD-2-Clause OR MIT
3
4// Own header
5#include "lchdouble.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::LchDouble. */
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(sizeof(LchDouble) == sizeof(cmsCIELCh));
27
28static_assert(std::is_trivially_copyable_v<LchDouble>);
29static_assert(std::is_trivial_v<LchDouble>);
30
31static_assert(std::is_standard_layout_v<LchDouble>);
32
33static_assert(std::is_default_constructible_v<LchDouble>);
34static_assert(std::is_trivially_default_constructible_v<LchDouble>);
35static_assert(std::is_nothrow_default_constructible_v<LchDouble>);
36
37static_assert(std::is_copy_constructible_v<LchDouble>);
38static_assert(std::is_trivially_copy_constructible_v<LchDouble>);
39static_assert(std::is_nothrow_copy_constructible_v<LchDouble>);
40
41static_assert(std::is_move_constructible_v<LchDouble>);
42static_assert(std::is_trivially_move_constructible_v<LchDouble>);
43static_assert(std::is_nothrow_move_constructible_v<LchDouble>);
44
45/** @brief Adds QDebug() support for data type
46 * @ref PerceptualColor::LchDouble
47 *
48 * @param dbg Existing debug object
49 * @param value Value to stream into the debug object
50 * @returns Debug object with value streamed in
51 *
52 * @internal
53 *
54 * @todo This is originally declared in the global namespace instead of
55 * the @ref PerceptualColor namespace, because the supported value was
56 * a <tt>typedef</tt> for a LittleCMS type in the global; when declaring
57 * this function in @ref PerceptualColor namespace, it did not work
58 * in the global namespace. Now, things have changed. But we should write
59 * a unit test for if it works in global namespace! */
60QDebug operator<<(QDebug dbg, const PerceptualColor::LchDouble &value)
61{
62 dbg.nospace() << "LchDouble(" << value.l << "% " << value.c << " " << value.h << "°)";
63 return dbg.maybeSpace();
64}
65
66/** @brief Compares coordinates with another object.
67 *
68 * @param other The object to compare with
69 * @returns <tt>true</tt> if all three coordinates @ref l, @ref c and @ref h
70 * of <em>this</em> object are all equal to the coordinates of <em>other</em>.
71 * <tt>false</tt> otherwise. Note that two objects with equal @ref l and
72 * equal @ref c, but one with h = 5° and the other with h = 365°, are
73 * considered non-equal thought both describe the same point in the
74 * coordinate space. */
76{
77 return ((l == other.l) && (c == other.c) && (h == other.h));
78}
79
80} // namespace PerceptualColor
The namespace of this library.
QDebug & maybeSpace()
QDebug & nospace()
A LCH color (Oklch, CielchD50, CielchD65…)
Definition lchdouble.h:50
bool hasSameCoordinates(const LchDouble &other) const
Compares coordinates with another object.
Definition lchdouble.cpp:75
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.