Perceptual Color

PerceptualColor::LchDouble Struct Reference

#include <lchdouble.h>

Public Member Functions

bool hasSameCoordinates (const LchDouble &other) const

Public Attributes

double c
double h
double l

Detailed Description

A LCH color (Oklch, CielchD50, CielchD65…)

Storage of floating point LCH values with double precision.

The data is not default-initialized; it is undefined when the object is created.


myValue.l = 50; // Lightness: 50%
myValue.c = 25; // Chroma: 25
myValue.h = 5; // Hue: 5°

More details about the valid range: Range of LCH values

This class intentionally does not provide the operators equal to (operator==) and not equal to (operator!=). As LCH colors are polar coordinates, there are various valid representations of the same angle. And h is even meaningless when C is zero; on the other hand, there might nevertheless be an interest in preserving h. And invalid values with L=200 or L=300: Should they be equal because both are invalid? Or are they different? The answer to all these questions depends on your use case. To avoid confusion, no comparison operators are provided by this class. See also hasSameCoordinates.

This type is declared as type to Qt’s type system via Q_DECLARE_METATYPE. Depending on your use case (for example if you want to use for queued signal-slot connections), you might consider calling qRegisterMetaType() for this type, once you have a QApplication object.

This data type can be passed to QDebug thanks to operator<<(QDebug dbg, const PerceptualColor::LchDouble &value)

Definition at line 50 of file lchdouble.h.

Member Function Documentation

◆ hasSameCoordinates()

bool PerceptualColor::LchDouble::hasSameCoordinates ( const LchDouble & other) const

Compares coordinates with another object.

otherThe object to compare with
true if all three coordinates l, c and h of this object are all equal to the coordinates of other. false otherwise. Note that two objects with equal l and equal c, but one with h = 5° and the other with h = 365°, are considered non-equal thought both describe the same point in the coordinate space.

Definition at line 75 of file lchdouble.cpp.

Member Data Documentation

◆ c

double PerceptualColor::LchDouble::c


0 means no chroma (grayscale). The maximum value depends on the gamut. For sRGB for example it’s a given value, but other gamuts can be bigger, but the practical limit is the gamut of the human perception, beyond which a Chroma value does not make sense.

Definition at line 63 of file lchdouble.h.

◆ h

double PerceptualColor::LchDouble::h

Hue, measured in degree.

The valid range is [0, 360[.

Definition at line 67 of file lchdouble.h.

◆ l

double PerceptualColor::LchDouble::l

Lightness, mesured in percent.

The valid range is [0, 100].

Definition at line 55 of file lchdouble.h.

The documentation for this struct was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 12:04:37 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.