Perceptual Color

PerceptualColor::LchaDouble Struct Reference

#include <lchadouble.h>

Public Member Functions

bool hasSameCoordinates (const LchaDouble &other) const
 

Public Attributes

double a
 
double c
 
double h
 
double l
 

Detailed Description

A LCH color with alpha channel.

Storage of floating point LCH values with double precision.

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

Example:

myValue.l = 50; // Lightness: 50%
myValue.c = 25; // Chroma: 25
myValue.h = 5; // Hue: 5°
myValue.a = 0.5; // Alpha: 0.5 (semi-transparent)

More details about the valid range: Range of LCH values

Note
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::LchaDouble &value)

Definition at line 51 of file lchadouble.h.

Member Function Documentation

◆ hasSameCoordinates()

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

Compares coordinates with another object.

Parameters
otherThe object to compare with
Returns
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 73 of file lchadouble.cpp.

Member Data Documentation

◆ a

double PerceptualColor::LchaDouble::a

Opacity (alpha channel)

The valid range is [0, 1]. 0 is fully transparent, 1 is fully opaque.

Definition at line 73 of file lchadouble.h.

◆ c

double PerceptualColor::LchaDouble::c

Chroma.

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 64 of file lchadouble.h.

◆ h

double PerceptualColor::LchaDouble::h

Hue, measured in degree.

The valid range is [0, 360[.

Definition at line 68 of file lchadouble.h.

◆ l

double PerceptualColor::LchaDouble::l

Lightness, mesured in percent.

The valid range is [0, 100].

Definition at line 56 of file lchadouble.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 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.