]> git.sesse.net Git - casparcg/blob - dependencies64/sfml/include/SFML/Graphics/Color.hpp
Updated some libraries to newer versions and/or versions compiled for vc12 (freeimage...
[casparcg] / dependencies64 / sfml / include / SFML / Graphics / Color.hpp
1 ////////////////////////////////////////////////////////////
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2014 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 //    you must not claim that you wrote the original software.
15 //    If you use this software in a product, an acknowledgment
16 //    in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 //    and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
23 ////////////////////////////////////////////////////////////
24
25 #ifndef SFML_COLOR_HPP
26 #define SFML_COLOR_HPP
27
28 ////////////////////////////////////////////////////////////
29 // Headers
30 ////////////////////////////////////////////////////////////
31 #include <SFML/Graphics/Export.hpp>
32
33
34 namespace sf
35 {
36 ////////////////////////////////////////////////////////////
37 /// \brief Utility class for manipulating RGBA colors
38 ///
39 ////////////////////////////////////////////////////////////
40 class SFML_GRAPHICS_API Color
41 {
42 public:
43
44     ////////////////////////////////////////////////////////////
45     /// \brief Default constructor
46     ///
47     /// Constructs an opaque black color. It is equivalent to
48     /// sf::Color(0, 0, 0, 255).
49     ///
50     ////////////////////////////////////////////////////////////
51     Color();
52
53     ////////////////////////////////////////////////////////////
54     /// \brief Construct the color from its 4 RGBA components
55     ///
56     /// \param red   Red component (in the range [0, 255])
57     /// \param green Green component (in the range [0, 255])
58     /// \param blue  Blue component (in the range [0, 255])
59     /// \param alpha Alpha (opacity) component (in the range [0, 255])
60     ///
61     ////////////////////////////////////////////////////////////
62     Color(Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha = 255);
63
64     ////////////////////////////////////////////////////////////
65     // Static member data
66     ////////////////////////////////////////////////////////////
67     static const Color Black;       ///< Black predefined color
68     static const Color White;       ///< White predefined color
69     static const Color Red;         ///< Red predefined color
70     static const Color Green;       ///< Green predefined color
71     static const Color Blue;        ///< Blue predefined color
72     static const Color Yellow;      ///< Yellow predefined color
73     static const Color Magenta;     ///< Magenta predefined color
74     static const Color Cyan;        ///< Cyan predefined color
75     static const Color Transparent; ///< Transparent (black) predefined color
76
77     ////////////////////////////////////////////////////////////
78     // Member data
79     ////////////////////////////////////////////////////////////
80     Uint8 r; ///< Red component
81     Uint8 g; ///< Green component
82     Uint8 b; ///< Blue component
83     Uint8 a; ///< Alpha (opacity) component
84 };
85
86 ////////////////////////////////////////////////////////////
87 /// \relates Color
88 /// \brief Overload of the == operator
89 ///
90 /// This operator compares two colors and check if they are equal.
91 ///
92 /// \param left  Left operand
93 /// \param right Right operand
94 ///
95 /// \return True if colors are equal, false if they are different
96 ///
97 ////////////////////////////////////////////////////////////
98 SFML_GRAPHICS_API bool operator ==(const Color& left, const Color& right);
99
100 ////////////////////////////////////////////////////////////
101 /// \relates Color
102 /// \brief Overload of the != operator
103 ///
104 /// This operator compares two colors and check if they are different.
105 ///
106 /// \param left  Left operand
107 /// \param right Right operand
108 ///
109 /// \return True if colors are different, false if they are equal
110 ///
111 ////////////////////////////////////////////////////////////
112 SFML_GRAPHICS_API bool operator !=(const Color& left, const Color& right);
113
114 ////////////////////////////////////////////////////////////
115 /// \relates Color
116 /// \brief Overload of the binary + operator
117 ///
118 /// This operator returns the component-wise sum of two colors.
119 /// Components that exceed 255 are clamped to 255.
120 ///
121 /// \param left  Left operand
122 /// \param right Right operand
123 ///
124 /// \return Result of \a left + \a right
125 ///
126 ////////////////////////////////////////////////////////////
127 SFML_GRAPHICS_API Color operator +(const Color& left, const Color& right);
128
129 ////////////////////////////////////////////////////////////
130 /// \relates Color
131 /// \brief Overload of the binary - operator
132 ///
133 /// This operator returns the component-wise subtraction of two colors.
134 /// Components below 0 are clamped to 0.
135 ///
136 /// \param left  Left operand
137 /// \param right Right operand
138 ///
139 /// \return Result of \a left - \a right
140 ///
141 ////////////////////////////////////////////////////////////
142 SFML_GRAPHICS_API Color operator -(const Color& left, const Color& right);
143
144 ////////////////////////////////////////////////////////////
145 /// \relates Color
146 /// \brief Overload of the binary * operator
147 ///
148 /// This operator returns the component-wise multiplication
149 /// (also called "modulation") of two colors.
150 /// Components are then divided by 255 so that the result is
151 /// still in the range [0, 255].
152 ///
153 /// \param left  Left operand
154 /// \param right Right operand
155 ///
156 /// \return Result of \a left * \a right
157 ///
158 ////////////////////////////////////////////////////////////
159 SFML_GRAPHICS_API Color operator *(const Color& left, const Color& right);
160
161 ////////////////////////////////////////////////////////////
162 /// \relates Color
163 /// \brief Overload of the binary += operator
164 ///
165 /// This operator computes the component-wise sum of two colors,
166 /// and assigns the result to the left operand.
167 /// Components that exceed 255 are clamped to 255.
168 ///
169 /// \param left  Left operand
170 /// \param right Right operand
171 ///
172 /// \return Reference to \a left
173 ///
174 ////////////////////////////////////////////////////////////
175 SFML_GRAPHICS_API Color& operator +=(Color& left, const Color& right);
176
177 ////////////////////////////////////////////////////////////
178 /// \relates Color
179 /// \brief Overload of the binary -= operator
180 ///
181 /// This operator computes the component-wise subtraction of two colors,
182 /// and assigns the result to the left operand.
183 /// Components below 0 are clamped to 0.
184 ///
185 /// \param left  Left operand
186 /// \param right Right operand
187 ///
188 /// \return Reference to \a left
189 ///
190 ////////////////////////////////////////////////////////////
191 SFML_GRAPHICS_API Color& operator -=(Color& left, const Color& right);
192
193 ////////////////////////////////////////////////////////////
194 /// \relates Color
195 /// \brief Overload of the binary *= operator
196 ///
197 /// This operator returns the component-wise multiplication
198 /// (also called "modulation") of two colors, and assigns
199 /// the result to the left operand.
200 /// Components are then divided by 255 so that the result is
201 /// still in the range [0, 255].
202 ///
203 /// \param left  Left operand
204 /// \param right Right operand
205 ///
206 /// \return Reference to \a left
207 ///
208 ////////////////////////////////////////////////////////////
209 SFML_GRAPHICS_API Color& operator *=(Color& left, const Color& right);
210
211 } // namespace sf
212
213
214 #endif // SFML_COLOR_HPP
215
216
217 ////////////////////////////////////////////////////////////
218 /// \class sf::Color
219 /// \ingroup graphics
220 ///
221 /// sf::Color is a simple color class composed of 4 components:
222 /// \li Red
223 /// \li Green
224 /// \li Blue
225 /// \li Alpha (opacity)
226 ///
227 /// Each component is a public member, an unsigned integer in
228 /// the range [0, 255]. Thus, colors can be constructed and
229 /// manipulated very easily:
230 ///
231 /// \code
232 /// sf::Color color(255, 0, 0); // red
233 /// color.r = 0;                // make it black
234 /// color.b = 128;              // make it dark blue
235 /// \endcode
236 ///
237 /// The fourth component of colors, named "alpha", represents
238 /// the opacity of the color. A color with an alpha value of
239 /// 255 will be fully opaque, while an alpha value of 0 will
240 /// make a color fully transparent, whatever the value of the
241 /// other components is.
242 ///
243 /// The most common colors are already defined as static variables:
244 /// \code
245 /// sf::Color black       = sf::Color::Black;
246 /// sf::Color white       = sf::Color::White;
247 /// sf::Color red         = sf::Color::Red;
248 /// sf::Color green       = sf::Color::Green;
249 /// sf::Color blue        = sf::Color::Blue;
250 /// sf::Color yellow      = sf::Color::Yellow;
251 /// sf::Color magenta     = sf::Color::Magenta;
252 /// sf::Color cyan        = sf::Color::Cyan;
253 /// sf::Color transparent = sf::Color::Transparent;
254 /// \endcode
255 ///
256 /// Colors can also be added and modulated (multiplied) using the
257 /// overloaded operators + and *.
258 ///
259 ////////////////////////////////////////////////////////////