GG
Clr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3  Copyright (C) 2003-2008 T. Zachary Laine
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public License
7  as published by the Free Software Foundation; either version 2.1
8  of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  02111-1307 USA
19 
20  If you do not wish to comply with the terms of the LGPL please
21  contact the author as other terms are available for a fee.
22 
23  Zach Laine
24  whatwasthataddress@gmail.com */
25 
29 #ifndef _GG_Clr_h_
30 #define _GG_Clr_h_
31 
32 #include <GG/Export.h>
33 
34 
35 namespace GG {
36 
45 struct GG_API Clr
46 {
48 
49  Clr() :
50  r(0), g(0), b(0), a(0)
51  {}
52 
54  Clr(unsigned char r_,
55  unsigned char g_,
56  unsigned char b_,
57  unsigned char a_) :
58  r(r_), g(g_), b(b_), a(a_)
59  {}
61 
62  unsigned char r;
63  unsigned char g;
64  unsigned char b;
65  unsigned char a;
66 };
67 
70 inline Clr FloatClr(float r, float g, float b, float a)
71 {
72  return Clr(static_cast<unsigned char>(r * 255),
73  static_cast<unsigned char>(g * 255),
74  static_cast<unsigned char>(b * 255),
75  static_cast<unsigned char>(a * 255));
76 }
77 
79 inline bool operator==(const Clr& rhs, const Clr& lhs)
80 { return rhs.r == lhs.r && rhs.g == lhs.g && rhs.b == lhs.b && rhs.a == lhs.a; }
81 
83 inline bool operator!=(const Clr& rhs, const Clr& lhs)
84 { return !(rhs == lhs); }
85 
86 } // namespace GG
87 
88 #endif
89