21 #include "hx3d/graphics/color.hpp" 27 r(255), g(255), b(255), a(255) {}
29 r(r), g(g), b(b),
a(255) {}
31 r(r), g(g), b(b), a(a) {}
43 return glm::vec4(
r/255.f,
g/255.f,
b/255.f,
a/255.f);
49 unsigned char region, remainder, p, q, t;
60 remainder = (hsv.
r - (region * 43)) * 6;
62 p = (hsv.
b * (255 - hsv.
g)) >> 8;
63 q = (hsv.
b * (255 - ((hsv.
g * remainder) >> 8))) >> 8;
64 t = (hsv.
b * (255 - ((hsv.
g * (255 - remainder)) >> 8))) >> 8;
69 rgb.
r = hsv.
b; rgb.
g = t; rgb.
b = p;
72 rgb.
r = q; rgb.
g = hsv.
b; rgb.
b = p;
75 rgb.
r = p; rgb.
g = hsv.
b; rgb.
b = t;
78 rgb.
r = p; rgb.
g = q; rgb.
b = hsv.
b;
81 rgb.
r = t; rgb.
g = p; rgb.
b = hsv.
b;
84 rgb.
r = hsv.
b; rgb.
g = p; rgb.
b = q;
94 unsigned char rgbMin, rgbMax;
96 rgbMin = rgb.
r < rgb.
g ? (rgb.
r < rgb.
b ? rgb.
r : rgb.
b) : (rgb.
g < rgb.
b ? rgb.
g : rgb.
b);
97 rgbMax = rgb.
r > rgb.
g ? (rgb.
r > rgb.
b ? rgb.
r : rgb.
b) : (rgb.
g > rgb.
b ? rgb.
g : rgb.
b);
107 hsv.
g = 255 * long(rgbMax - rgbMin) / hsv.
b;
115 hsv.
r = 0 + 43 * (rgb.
g - rgb.
b) / (rgbMax - rgbMin);
116 else if (rgbMax == rgb.
g)
117 hsv.
r = 85 + 43 * (rgb.
b - rgb.
r) / (rgbMax - rgbMin);
119 hsv.
r = 171 + 43 * (rgb.
r - rgb.
g) / (rgbMax - rgbMin);
glm::vec4 toFloat()
Convert the color to a float format (between 0 and 1).
unsigned char a
Alpha component.
unsigned char g
Green component.
static Color hsvToRgb(Color hsv)
Convert HSV color to RGB format.
Four [0..255] components defined color.
static Color Red
Red color.
static Color White
White color.
Color()
Create a white color.
static Color Blue
Blue color.
Color & operator=(const Color &color)
Affect a color into another.
static Color rgbToHsv(Color rgb)
Convert RGB color to HSV format.
static Color Green
Green color.
static Color Black
Black color.
unsigned char b
Blue component.
unsigned char r
Red component.