1 ////////////////////////////////////////////////////////////
\r
3 // SFML - Simple and Fast Multimedia Library
\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
\r
6 // This software is provided 'as-is', without any express or implied warranty.
\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.
\r
9 // Permission is granted to anyone to use this software for any purpose,
\r
10 // including commercial applications, and to alter it and redistribute it freely,
\r
11 // subject to the following restrictions:
\r
13 // 1. The origin of this software must not be misrepresented;
\r
14 // you must not claim that you wrote the original software.
\r
15 // If you use this software in a product, an acknowledgment
\r
16 // in the product documentation would be appreciated but is not required.
\r
18 // 2. Altered source versions must be plainly marked as such,
\r
19 // and must not be misrepresented as being the original software.
\r
21 // 3. This notice may not be removed or altered from any source distribution.
\r
23 ////////////////////////////////////////////////////////////
\r
25 #ifndef SFML_COLOR_HPP
\r
26 #define SFML_COLOR_HPP
\r
28 ////////////////////////////////////////////////////////////
\r
30 ////////////////////////////////////////////////////////////
\r
31 #include <SFML/Config.hpp>
\r
36 ////////////////////////////////////////////////////////////
\r
37 /// Color is an utility class for manipulating
\r
38 /// 32-bits RGBA colors
\r
39 ////////////////////////////////////////////////////////////
\r
40 class SFML_API Color
\r
44 ////////////////////////////////////////////////////////////
\r
45 /// Default constructor
\r
47 ////////////////////////////////////////////////////////////
\r
50 ////////////////////////////////////////////////////////////
\r
51 /// Construct the color from its 4 RGBA components
\r
53 /// \param R : Red component (0 .. 255)
\r
54 /// \param G : Green component (0 .. 255)
\r
55 /// \param B : Blue component (0 .. 255)
\r
56 /// \param A : Alpha component (0 .. 255) (255 by default)
\r
58 ////////////////////////////////////////////////////////////
\r
59 Color(Uint8 R, Uint8 G, Uint8 B, Uint8 A = 255);
\r
61 ////////////////////////////////////////////////////////////
\r
62 /// Operator += overload to add a color
\r
64 /// \param Other : Color to add
\r
66 /// \return Component-wise saturated addition of the two colors
\r
68 ////////////////////////////////////////////////////////////
\r
69 Color& operator +=(const Color& Other);
\r
71 ////////////////////////////////////////////////////////////
\r
72 /// Operator *= overload to modulate a color
\r
74 /// \param Other : Color to modulate
\r
76 /// \return Component-wise multiplication of the two colors
\r
78 ////////////////////////////////////////////////////////////
\r
79 Color& operator *=(const Color& Other);
\r
81 ////////////////////////////////////////////////////////////
\r
82 /// Compare two colors (for equality)
\r
84 /// \param Other : Color to compare
\r
86 /// \return True if colors are equal
\r
88 ////////////////////////////////////////////////////////////
\r
89 bool operator ==(const Color& Other) const;
\r
91 ////////////////////////////////////////////////////////////
\r
92 /// Compare two colors (for difference)
\r
94 /// \param Other : Color to compare
\r
96 /// \return True if colors are different
\r
98 ////////////////////////////////////////////////////////////
\r
99 bool operator !=(const Color& Other) const;
\r
101 ////////////////////////////////////////////////////////////
\r
102 // Static member data
\r
103 ////////////////////////////////////////////////////////////
\r
104 static const Color Black; ///< Black predefined color
\r
105 static const Color White; ///< White predefined color
\r
106 static const Color Red; ///< Red predefined color
\r
107 static const Color Green; ///< Green predefined color
\r
108 static const Color Blue; ///< Blue predefined color
\r
109 static const Color Yellow; ///< Yellow predefined color
\r
110 static const Color Magenta; ///< Magenta predefined color
\r
111 static const Color Cyan; ///< Cyan predefined color
\r
113 ////////////////////////////////////////////////////////////
\r
115 ////////////////////////////////////////////////////////////
\r
116 Uint8 r; ///< Red component
\r
117 Uint8 g; ///< Green component
\r
118 Uint8 b; ///< Blue component
\r
119 Uint8 a; ///< Alpha (transparency) component
\r
122 ////////////////////////////////////////////////////////////
\r
123 /// Operator + overload to add two colors
\r
125 /// \param Color1 : First color
\r
126 /// \param Color2 : Second color
\r
128 /// \return Component-wise saturated addition of the two colors
\r
130 ////////////////////////////////////////////////////////////
\r
131 SFML_API Color operator +(const Color& Color1, const Color& Color2);
\r
133 ////////////////////////////////////////////////////////////
\r
134 /// Operator * overload to modulate two colors
\r
136 /// \param Color1 : First color
\r
137 /// \param Color2 : Second color
\r
139 /// \return Component-wise multiplication of the two colors
\r
141 ////////////////////////////////////////////////////////////
\r
142 SFML_API Color operator *(const Color& Color1, const Color& Color2);
\r
147 #endif // SFML_COLOR_HPP
\r