41 explicit Color(
float aR = 0.0f,
float aG = 0.0f,
float aB = 0.0f,
float aA = 0.0f)
42 :
r(aR), g(aG), b(aB), a(aA) {}
44 inline Color Inverse()
const
46 return Color(1.0f -
r, 1.0f - g, 1.0f - b, 1.0f - a);
52 return reinterpret_cast<float*
>(
this);
56 inline const float*
Array()
const
58 return reinterpret_cast<const float*
>(
this);
66 s <<
"(" <<
r <<
", " << g <<
", " << b <<
", " << a <<
")";
70 inline bool operator==(
const Color &other)
const
72 return r == other.
r && g == other.g && b == other.b && a == other.a;
75 inline bool operator!=(
const Color &other)
const
77 return ! this->operator==(other);
80 inline Color operator*(
float scale)
const
100 unsigned char r, g, b, a;
103 explicit IntColor(
unsigned char aR = 0,
unsigned char aG = 0,
unsigned char aB = 0,
unsigned char aA = 0)
104 :
r(aR), g(aG), b(aB), a(aA) {}
107 inline Color IntColorToColor(IntColor color)
109 return Color(color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f);
112 inline IntColor ColorToIntColor(Color color)
114 return IntColor(static_cast<unsigned char>(color.r * 255.0f),
115 static_cast<unsigned char>(color.g * 255.0f),
116 static_cast<unsigned char>(color.b * 255.0f),
117 static_cast<unsigned char>(color.a * 255.0f));
120 inline Color IntensityToColor(
float intensity)
122 if (intensity <= 0.0f)
return Color(0.0f, 0.0f, 0.0f, 0.0f);
123 if (intensity >= 1.0f)
return Color(1.0f, 1.0f, 1.0f, 1.0f);
125 return Color(intensity, intensity, intensity, intensity);
136 ColorHSV(
float aH = 0.0f,
float aS = 0.0f,
float aV = 0.0f)
137 : h(aH), s(aS), v(aV) {}
142 std::stringstream str;
144 str <<
"(" << h <<
", " << s <<
", " << v <<
")";