43 * @param [in] red The Color r.
44 * @param [in] green The Color g.
45 * @param [in] blue The Color b.
46 * @param [in] alpha The Color a.
48 public Color(float red, float green, float blue, float alpha)
60 * @param [in] o The Vector4 having r g b a components
62 public Color(Vector4 o)
75 * @param [in] color as enum Colors.
77 public Color(Colors color)
82 SetColor(1.0f, 0.0f, 0.0f, 1.0f);
85 SetColor(1.0f, 1.0f, 1.0f, 1.0f);
88 SetColor(0.0f, 0.0f, 1.0f, 1.0f);
91 SetColor(0.0f, 1.0f, 0.0f, 1.0f);
94 SetColor(0.0f, 0.0f, 0.0f, 1.0f);
97 SetColor(1.0f, 1.0f, 0.0f, 1.0f);
100 SetColor(0.0f, 1.0f, 1.0f, 1.0f);
103 SetColor(1.0f, 0.0f, 1.0f, 1.0f);
113 * @param [in] red The Color r.
114 * @param [in] green The Color g.
115 * @param [in] blue The Color b.
116 * @param [in] alpha The Color a.
118 public void SetColor(float red, float green, float blue, float alpha)
127 * @brief name "R", type float (Color's Red component)
138 * @brief name "G", type float (Color's Green component)
148 * @brief name "B", type float (Color's Blue component)
158 * @brief name "A", type float (Color's Alpha value)
171 * @param [in] l The Color to add.
172 * @param [in] r The Color to add
173 * @return A reference to this
175 public static Color operator +(Color l, Color r)
177 return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A);
184 * @param [in] l The Color to substract.
185 * @param [in] r The Color to substract
186 * @return A reference to this
188 public static Color operator -(Color l, Color r)
190 return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A);
197 * @param [in] a The Color to multiply.
198 * @param [in] b The constant double to multiply.
199 * @return A reference to this
201 public static Color operator *(Color a, double b)
203 return new Color((float)(a.R * b), (float)(a.G * b), (float)(a.B * b), (float)(a.A * b));
210 * @param [in] a The Color to divide.
211 * @param [in] b The Color to divide
212 * @return float value of division operation
214 public static float operator /(Color a, Color b)
216 return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A));
223 * @param [in] x The Color object to compare.
224 * @param [in] y The Color object to compare.
225 * @return bool, whether colors are equal or not
227 public static bool operator == (Color x, Color y)
229 return x.R == y.R && x.G == y.G && x.B == y.B && x.A == y.A;
236 * @param [in] x The Color object to compare.
237 * @param [in] y The Color object to compare.
238 * @return bool, whether colors are equal or not
240 public static bool operator != (Color x, Color y)
242 return x.R != y.R || x.G != y.G || x.B != y.B || x.A != y.A;
249 * @return int, hascode of Color
251 public override int GetHashCode()
253 return base.GetHashCode();
260 * @return Color object
264 Color copy = new Color(R, G, B, A);
268 // Create a color for RGBA values ranging from 0..255, useful when dealing with HTML colors
269 static Color FromRgbaByte( byte red, byte green, byte blue, byte alpha )
271 return new Color ( red / 255, green / 255, blue / 255, alpha / 255 );
274 // User-defined conversion from Color to Vector4
275 public static implicit operator Vector4(Color color)
277 return new Vector4(color.r, color.g, color.b, color.a);
280 public static implicit operator Color(Vector4 vec)
282 return new Color(vec.r, vec.g, vec.b, vec.a);
286 * @brief name "White", type Color (White Color object)
289 public static Color White
293 return new Color(Colors.White);
298 * @brief name "Black", type Color (Black Color object)
301 public static Color Black
305 return new Color(Colors.Black);
310 * @brief name "Red", type Color (Red Color object)
313 public static Color Red
317 return new Color(Colors.Red);
322 * @brief name "Green", type Color (Green Color object)
325 public static Color Green
329 return new Color(Colors.Green);
334 * @brief name "Blue", type Color (Blue Color object)
337 public static Color Blue
341 return new Color(Colors.Blue);
346 * @brief name "Yellow", type Color (Yellow Color object)
349 public static Color Yellow
353 return new Color(Colors.Yellow);
358 * @brief name "Magenta", type Color (Magenta Color object)
361 public static Color Magenta
365 return new Color(Colors.Magenta);
370 * @brief name "Cyan", type Color (Cyan Color object)
373 public static Color Cyan
377 return new Color(Colors.Cyan);