1 /********************************************************************************
2 * OpenGL-Framework                                                              *
3 * Copyright (c) 2013 Daniel Chappuis                                            *
4 *********************************************************************************
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  *
8 * use of this software.                                                         *
9 *                                                                               *
10 * Permission is granted to anyone to use this software for any purpose,         *
11 * including commercial applications, and to alter it and redistribute it        *
12 * freely, subject to the following restrictions:                                *
13 *                                                                               *
14 * 1. The origin of this software must not be misrepresented; you must not claim *
15 *    that you wrote the original software. If you use this software in a        *
16 *    product, an acknowledgment in the product documentation would be           *
17 *    appreciated but is not required.                                           *
18 *                                                                               *
19 * 2. Altered source versions must be plainly marked as such, and must not be    *
20 *    misrepresented as being the original software.                             *
21 *                                                                               *
22 * 3. This notice may not be removed or altered from any source distribution.    *
23 *                                                                               *
24 ********************************************************************************/
25 
26 #ifndef COLOR_H
27 #define COLOR_H
28 
29 namespace openglframework {
30 
31 // Structure Color
32 // This structure represents a RGBA color.
33 struct Color {
34 
35     public:
36 
37         // -------------------- Attributes -------------------- //
38 
39         // RGBA color components
40         float r, g, b, a;
41 
42         // -------------------- Methods -------------------- //
43 
44         // Constructor
ColorColor45         Color() : r(1), g(1), b(1), a(1) {}
46 
47         // Constructor
ColorColor48         Color(float r, float g, float b, float a) : r(r), g(g), b(b), a(a) {}
49 
50         // Copy-constructor
ColorColor51         Color(const Color& color) : r(color.r), g(color.g), b(color.b), a(color.a) {}
52 
53         // Destructor
~ColorColor54         ~Color() {}
55 
56         // Return the black color
blackColor57         static Color black() { return Color(0.0f, 0.0f, 0.0f, 1.0f);}
58 
59         // Return the white color
whiteColor60         static Color white() { return Color(1.0f, 1.0f, 1.0f, 1.0f);}
61 
62         // Return the red color
redColor63         static Color red() { return Color(1.0f, 0.0f, 0.0f, 1.0f);}
64 
65         // Return the green color
greenColor66         static Color green() { return Color(0.0f, 1.0f, 0.0f, 1.0f);}
67 
68         // Return the blue color
blueColor69         static Color blue() { return Color(0.0f, 0.0f, 1.0f, 1.0f);}
70 
71         // = operator
72         Color& operator=(const Color& color) {
73             if (&color != this) {
74                 r = color.r;
75                 g = color.g;
76                 b = color.b;
77                 a = color.a;
78             }
79             return *this;
80         }
81 };
82 
83 }
84 
85 #endif
86