hx3d  1
2D/3D Simple Game Framework
color.hpp
1 /*
2  Color.
3  Copyright (C) 2015 Denis BOURGE
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
7  License as published by the Free Software Foundation; either
8  version 2.1 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 Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_GRAPHICS_COLOR
22 #define HX3D_GRAPHICS_COLOR
23 
24 #include <glm/vec4.hpp>
25 
26 namespace hx3d {
27 namespace graphics {
28 
32 class Color {
33 
34 public:
38  Color();
39 
47  Color(unsigned char r, unsigned char g, unsigned char b);
48 
57  Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
58 
66  Color& operator=(const Color& color);
67 
73  glm::vec4 toFloat();
74 
76 
84  static Color hsvToRgb(Color hsv);
85 
93  static Color rgbToHsv(Color rgb);
94 
96  unsigned char r;
98  unsigned char g;
100  unsigned char b;
102  unsigned char a;
103 
105 
107  static Color White;
109  static Color Black;
111  static Color Red;
113  static Color Green;
115  static Color Blue;
116 };
117 
118 } /* graphics */
119 } /* hx3d */
120 
121 #endif
glm::vec4 toFloat()
Convert the color to a float format (between 0 and 1).
Definition: color.cpp:42
unsigned char a
Alpha component.
Definition: color.hpp:102
unsigned char g
Green component.
Definition: color.hpp:98
static Color hsvToRgb(Color hsv)
Convert HSV color to RGB format.
Definition: color.cpp:46
Four [0..255] components defined color.
Definition: color.hpp:32
static Color Red
Red color.
Definition: color.hpp:111
static Color White
White color.
Definition: color.hpp:107
hx3d framework namespace
Definition: audio.hpp:26
Color()
Create a white color.
Definition: color.cpp:26
static Color Blue
Blue color.
Definition: color.hpp:115
Color & operator=(const Color &color)
Affect a color into another.
Definition: color.cpp:33
static Color rgbToHsv(Color rgb)
Convert RGB color to HSV format.
Definition: color.cpp:91
static Color Green
Green color.
Definition: color.hpp:113
static Color Black
Black color.
Definition: color.hpp:109
unsigned char b
Blue component.
Definition: color.hpp:100
unsigned char r
Red component.
Definition: color.hpp:96