23#include "util/colordictionary.h"
34 name = theName.
isNull() ? ColorRef::getDefaultColorName(theColor) : theName;
37bool ColorRef::operator==(
ColorRef colorRef1)
39 if ( (color == colorRef1.color) && (name == colorRef1.name) )
49bool ColorRef::operator!=(
ColorRef colorRef1)
51 if ( (color != colorRef1.color) || (name != colorRef1.name) )
63 debug.
nospace() <<
"ColorRef(" << colorRef.color <<
" " << colorRef.name <<
")";
70 const int r = c.
red();
71 const int g = c.
green();
72 const int b = c.
blue();
76 const qreal x = 0.412453*r + 0.357580*g + 0.180423*b;
77 const qreal y = 0.212671*r + 0.715160*g + 0.072169*b;
78 const qreal z = 0.019334*r + 0.119193*g + 0.950227*b;
83 auto f = [](
const double a) {
return a > 0.008856 ? std::cbrt(a) : 7.787 * a + 16 / 116; };
85 const qreal xn = 95.047,
88 const qreal l = y / yn > 0.008856 ? 116 * cbrt(y / yn) - 16 : 903.3*y / yn,
89 u = 500 * (f(x / xn) - f(y / yn)),
90 v = 200 * (f(y / yn) - f(z / zn));
94 if (u < 0.01 && u > -0.01 && v < 0.01 && v > -0.01)
97 qreal minDist = qPow(colorDict[dictSize - 5][0] - l, 2) + qPow(colorDict[dictSize - 5][1] - u, 2) + qPow(colorDict[dictSize - 5][2] - v, 2);
98 for (
int i = dictSize - 4; i < dictSize; i++)
100 qreal curDist = qPow(colorDict[i][0] - l, 2) + qPow(colorDict[i][1] - u, 2) + qPow(colorDict[i][2] - v, 2);
101 if (curDist < minDist)
110 qreal minDist = qPow(colorDict[0][0] - l, 2) + qPow(colorDict[0][1] - u, 2) + qPow(colorDict[0][2] - v, 2);
111 for (
int i = 1; i < dictSize; i++)
113 qreal curDist = qPow(colorDict[i][0] - l, 2) + qPow(colorDict[i][1] - u, 2) + qPow(colorDict[i][2] - v, 2);
114 if (curDist < minDist)
121 return tr(nameDict[minLoc]);
bool isNull() const const