8float Color::power( )
const
13float Color::max( )
const
15 return std::max(r, std::max(g, std::max(b,
float(0))));
20 return Color(0, 0, 0);
25 return Color(1, 1, 1);
30 return Color(1, 0, 0);
35 return Color(0, 1, 0);
40 return Color(0, 0, 1);
45 return Color(1, 1, 0);
49float srgb(
const float x )
51 if(x < 0.00031308f)
return 12.92f * x;
52 else return std::pow(1.055f * x, 1.0f / 2.4f) - 0.055f;
55float linear(
const float x )
57 if(x < 0.04045f)
return x / 12.92f;
58 else return std::pow((x + 0.055f) / 1.055f, 2.4f);
63 return Color(srgb(color.r), srgb(color.g), srgb(color.b), color.a);
69 return Color(linear(color.r), linear(color.g), linear(color.b), color.a);
75 return Color(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a);
80 return Color(-c.r, -c.g, -c.b, -c.a);
90 return Color(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a);
93Color operator* (
const float k,
const Color& c )
95 return Color(c.r * k, c.g * k, c.b * k, c.a * k);
98Color operator* (
const Color& c,
const float k )
105 return Color(a.r / b.r, a.g / b.g, a.b / b.b, a.a / b.a);
108Color operator/ (
const float k,
const Color& c )
110 return Color(k / c.r, k / c.g, k / c.b, k / c.a);
113Color operator/ (
const Color& c,
const float k )
119Color operator+ (
const float k,
const Color& c )
121 return Color(k + c.r, k + c.g, k + c.b, k + c.a);
124Color operator+ (
const Color& c,
const float k )
131 return Color( std::abs(color.r), std::abs(color.g), std::abs(color.b), std::abs(color.a) );
Color Red()
utilitaire. renvoie une couleur rouge.
Color Yellow()
utilitaire. renvoie une couleur jaune.
Color Blue()
utilitaire. renvoie une couleur bleue.
Color Black()
utilitaire. renvoie une couleur noire.
Color Green()
utilitaire. renvoie une couleur verte.
Color White()
utilitaire. renvoie une couleur blanche.
representation d'une couleur (rgba) transparente ou opaque.