27 template <
typename T1>
29 :
Vector<4, T>(color[0] * scale, color[1] * scale, color[2] * scale, color[3] * scale)
33 template <
typename T1>
35 :
Vector<4, T>(color[0] * scale, color[1] * scale, color[2] * scale, color[3] * scale)
39 Color(
const Vector<4, T>& copy)
45 convertFromQColor(*
this, c);
55 Color(
const T&
r = T(),
const T&
g = T(),
const T&
b = T(),
const T&
a = T())
119 void r(
const T& val) {
126 void g(
const T& val) {
133 void b(
const T& val) {
140 void a(
const T& val) {
148 convertFromQColor(*
this, c);
151 operator QColor()
const {
return convertToQColor(*
this); }
154 mgx_EXPORT
QColor convertToQColor(
const Color<float>& c);
155 mgx_EXPORT
QColor convertToQColor(
const Color<double>& c);
156 mgx_EXPORT
QColor convertToQColor(
const Color<long double>& c);
157 mgx_EXPORT
QColor convertToQColor(
const Color<unsigned char>& c);
158 mgx_EXPORT
QColor convertToQColor(
const Color<unsigned short>& c);
159 mgx_EXPORT
QColor convertToQColor(
const Color<unsigned int>& c);
160 mgx_EXPORT
QColor convertToQColor(
const Color<unsigned long>& c);
161 mgx_EXPORT
QColor convertToQColor(
const Color<unsigned long long>& c);
162 mgx_EXPORT
QColor convertToQColor(
const Color<char>& c);
163 mgx_EXPORT
QColor convertToQColor(
const Color<short>& c);
164 mgx_EXPORT
QColor convertToQColor(
const Color<int>& c);
165 mgx_EXPORT
QColor convertToQColor(
const Color<long>& c);
166 mgx_EXPORT
QColor convertToQColor(
const Color<long long>& c);
168 mgx_EXPORT
void convertFromQColor(Color<float>& c,
const QColor& col);
169 mgx_EXPORT
void convertFromQColor(Color<double>& c,
const QColor& col);
170 mgx_EXPORT
void convertFromQColor(Color<long double>& c,
const QColor& col);
171 mgx_EXPORT
void convertFromQColor(Color<unsigned char>& c,
const QColor& col);
172 mgx_EXPORT
void convertFromQColor(Color<unsigned short>& c,
const QColor& col);
173 mgx_EXPORT
void convertFromQColor(Color<unsigned int>& c,
const QColor& col);
174 mgx_EXPORT
void convertFromQColor(Color<unsigned long>& c,
const QColor& col);
175 mgx_EXPORT
void convertFromQColor(Color<unsigned long long>& c,
const QColor& col);
176 mgx_EXPORT
void convertFromQColor(Color<char>& c,
const QColor& col);
177 mgx_EXPORT
void convertFromQColor(Color<short>& c,
const QColor& col);
178 mgx_EXPORT
void convertFromQColor(Color<int>& c,
const QColor& col);
179 mgx_EXPORT
void convertFromQColor(Color<long>& c,
const QColor& col);
180 mgx_EXPORT
void convertFromQColor(Color<long long>& c,
const QColor& col);
202 template <
class T> Color<T> convertHSVtoRGB(T h, T s, T v)
219 double p = v * (1 - s);
220 double q = v * (1 - (s * f));
221 double t = v * (1 - (s * (1 - f)));
260 template <
class T> Color<T> convertHSVtoRGB(
const Color<T>& hsv)
277 int i = (int)floor(h);
280 double p = v * (1 - s);
281 double q = v * (1 - (s * f));
282 double t = v * (1 - (s * (1 - f)));
321 template <
class T> Color<T> convertRGBtoHSV(
const Color<T>& rgb)
329 T M = std::max(std::max(r, g), b);
330 T m = std::min(std::min(r, g), b);
337 h = fmod((g - b) / c, 6);
350 return Color<T>(h, s, v, rgb.a());
Defines the util::clamp function.
A utility class to encapsulate color data.
Definition: Color.hpp:22
Color(const Vector< 4, T1 > &color, const T &scale=1)
Constructor to convert from one color type to another.
Definition: Color.hpp:28
T & b()
Return the blue component.
Definition: Color.hpp:77
const T & r() const
Return the red component.
Definition: Color.hpp:91
const T & a() const
Return the alpha component.
Definition: Color.hpp:112
T & r()
Return the red component.
Definition: Color.hpp:63
void g(const T &val)
Set the green component.
Definition: Color.hpp:126
CU_HOST_DEVICE T & y()
Short access to the second element.
Definition: Vector.hpp:696
CU_HOST_DEVICE T & t()
Short access to the fourth element.
Definition: Vector.hpp:714
void r(const T &val)
Set the red component.
Definition: Color.hpp:119
T & a()
Return the alpha component.
Definition: Color.hpp:84
CU_HOST_DEVICE Vector(const Vector &vec)
Copy another vector.
Definition: Vector.hpp:54
T & g()
Return the green component.
Definition: Color.hpp:70
CU_HOST_DEVICE T & x()
Short access to the first element.
Definition: Vector.hpp:687
const T & g() const
Return the green component.
Definition: Color.hpp:98
Namespace containing all the utility classes.
Definition: Vector.hpp:37
const T & b() const
Return the blue component.
Definition: Color.hpp:105
CU_HOST_DEVICE T & z()
Short access to the third element.
Definition: Vector.hpp:705
Color(const T &r=T(), const T &g=T(), const T &b=T(), const T &a=T())
Constructor.
Definition: Color.hpp:55
Color< T > & operator=(const Color< T > &c)
Assignment of color data.
Definition: Color.hpp:183
void a(const T &val)
Set the alpha component.
Definition: Color.hpp:140
void b(const T &val)
Set the blue component.
Definition: Color.hpp:133
Defines the Vector class template This file is shared by cuda, do not include headers that nvcc can't...
CU_HOST_DEVICE Vector & operator=(const Vector &vec)
Vector copy.
Definition: Vector.hpp:387