Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
cielab.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright 2005, 2006 by Gerald Friedland, Kristian Jantz and Lars Knipping
4 * Conversion to C++ for Inkscape by Bob Jamison
5 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
6 */
7#ifndef INKSCAPE_TRACE_CIELAB_H
8#define INKSCAPE_TRACE_CIELAB_H
9
10#include <cstdint>
11
12namespace Inkscape {
13namespace Trace {
14
15class CieLab
16{
17public:
19 {
20 C = 0;
21 L = A = B = 0.0f;
22 }
23
27 CieLab(uint32_t rgb);
28
29 CieLab(float l, float a, float b)
30 {
31 C = 0;
32 L = l;
33 A = a;
34 B = b;
35 }
36
37 CieLab(CieLab const &other)
38 {
39 C = other.C;
40 L = other.L;
41 A = other.A;
42 B = other.B;
43 }
44
45 CieLab &operator=(CieLab const &other)
46 {
47 C = other.C;
48 L = other.L;
49 A = other.A;
50 B = other.B;
51 return *this;
52 }
53
57 float operator()(unsigned index) const
58 {
59 switch (index) {
60 case 0: return L;
61 case 1: return A;
62 case 2: return B;
63 default: return 0;
64 }
65 }
66
67 void add(CieLab const &other)
68 {
69 C += other.C;
70 L += other.L;
71 A += other.A;
72 B += other.B;
73 }
74
75 void mul(float scale)
76 {
77 L *= scale;
78 A *= scale;
79 B *= scale;
80 }
81
85 uint32_t toRGB() const;
86
90 static float diffSq(CieLab const &c1, CieLab const &c2);
91
95 static float diff(CieLab const &c1, CieLab const &c2);
96
97 unsigned C;
98 float L;
99 float A;
100 float B;
101};
102
103} // namespace Trace
104} // namespace Inkscape
105
106#endif // INKSCAPE_TRACE_CIELAB_H
double scale
Definition aa.cpp:228
void add(CieLab const &other)
Definition cielab.h:67
CieLab & operator=(CieLab const &other)
Definition cielab.h:45
float operator()(unsigned index) const
Retrieve a CieLab value via index.
Definition cielab.h:57
uint32_t toRGB() const
Return this CieLab's value converted to an ARGB value.
Definition cielab.cpp:162
void mul(float scale)
Definition cielab.h:75
static float diff(CieLab const &c1, CieLab const &c2)
Computes euclidean distance in CieLab space between two colors.
Definition cielab.cpp:210
static float diffSq(CieLab const &c1, CieLab const &c2)
Squared Euclidean distance between two colors in CieLab space.
Definition cielab.cpp:203
CieLab(CieLab const &other)
Definition cielab.h:37
CieLab(float l, float a, float b)
Definition cielab.h:29
Helper class to stream background task notifications as a series of messages.
RGB rgb
Definition quantize.cpp:36
int index