Color.cpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00026 // Headers
00028 #include <SFML/Graphics/Color.hpp>
00029 
00030 
00031 namespace sf
00032 {
00034 // Static member data
00036 const Color Color::Black(0, 0, 0);
00037 const Color Color::White(255, 255, 255);
00038 const Color Color::Red(255, 0, 0);
00039 const Color Color::Green(0, 255, 0);
00040 const Color Color::Blue(0, 0, 255);
00041 const Color Color::Yellow(255, 255, 0);
00042 const Color Color::Magenta(255, 0, 255);
00043 const Color Color::Cyan(0, 255, 255);
00044 
00045 
00049 Color::Color() :
00050 r(0),
00051 g(0),
00052 b(0),
00053 a(255)
00054 {
00055 
00056 }
00057 
00058 
00062 Color::Color(Uint32 ColorRGBA) :
00063 r(static_cast<Uint8>((ColorRGBA & 0x000000FF))),
00064 g(static_cast<Uint8>((ColorRGBA & 0x0000FF00) >> 8)),
00065 b(static_cast<Uint8>((ColorRGBA & 0x00FF0000) >> 16)),
00066 a(static_cast<Uint8>((ColorRGBA & 0xFF000000) >> 24))
00067 {
00068 
00069 }
00070 
00071 
00075 Color::Color(Uint8 R, Uint8 G, Uint8 B, Uint8 A) :
00076 r(R),
00077 g(G),
00078 b(B),
00079 a(A)
00080 {
00081 
00082 }
00083 
00084 
00088 Uint32 Color::ToRGBA() const
00089 {
00090     return (a << 24) | (b << 16) | (g << 8) | r;
00091 }
00092 
00093 
00097 bool Color::operator ==(const Color& Other) const
00098 {
00099     return (r == Other.r) && (g == Other.g) && (b == Other.b) && (a == Other.a);
00100 }
00101 
00102 
00106 bool Color::operator !=(const Color& Other) const
00107 {
00108     return (r != Other.r) || (g != Other.g) || (b != Other.b) || (a != Other.a);
00109 }
00110 
00111 } // namespace sf