Gamedev Framework (gf)  0.5.0
A C++11 framework for 2D games
Color.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * 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
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_COLOR_H
22 #define GF_COLOR_H
23 
24 #include "Portability.h"
25 #include "Vector.h"
26 
27 namespace gf {
28 #ifndef DOXYGEN_SHOULD_SKIP_THIS
29 inline namespace v1 {
30 #endif
31 
44  struct GF_API Color {
48  Color() = delete;
49 
53  static constexpr Color4f Black{0.0f, 0.0f, 0.0f, 1.0f};
54 
58  static constexpr Color4f White{1.0f, 1.0f, 1.0f, 1.0f};
59 
63  static constexpr Color4f Red{1.0f, 0.0f, 0.0f, 1.0f};
64 
68  static constexpr Color4f Green{0.0f, 1.0f, 0.0f, 1.0f};
69 
73  static constexpr Color4f Blue{0.0f, 0.0f, 1.0f, 1.0f};
74 
78  static constexpr Color4f Cyan{0.0f, 1.0f, 1.0f, 1.0f};
79 
83  static constexpr Color4f Magenta{1.0f, 0.0f, 1.0f, 1.0f};
84 
88  static constexpr Color4f Yellow{1.0f, 1.0f, 0.0f, 1.0f};
89 
93  static constexpr Color4f Transparent{0.0f, 0.0f, 0.0f, 0.0f};
94 
100  static constexpr Color4f Opaque(float value = 0.5f) {
101  return { 1.0f, 1.0f, 1.0f, value };
102  }
103 
109  static constexpr Color4f Gray(float value = 0.5f) {
110  return { value, value, value, 1.0f };
111  }
112 
116  static constexpr Color4f Orange{1.0f, 0.5f, 0.0f, 1.0f};
117 
121  static constexpr Color4f Rose{1.0f, 0.0f, 0.5f, 1.0f};
122 
126  static constexpr Color4f Chartreuse{0.5f, 1.0f, 0.0f, 1.0f};
127 
131  static constexpr Color4f Spring{0.0f, 1.0f, 0.5f, 1.0f};
132 
136  static constexpr Color4f Violet{0.5f, 0.0f, 1.0f, 1.0f};
137 
141  static constexpr Color4f Azure{0.0f, 0.5f, 1.0f, 1.0f};
142 
143 
154  static Color4f lighter(Color4f color, float percent = 0.5f);
155 
166  static Color4f darker(Color4f color, float percent = 0.5f);
167 
177  static Color4f fromRgba32(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
178 
185  static Color4f fromRgba32(uint32_t color);
186 
193  static Color4f fromRgba32(Color4u color);
194 
201  static Color4u toRgba32(Color4f color);
202 
203  };
204 
205 #ifndef DOXYGEN_SHOULD_SKIP_THIS
206 }
207 #endif
208 }
209 
210 #endif // GF_COLOR_H
A red and gray style.
static constexpr Color4f Gray(float value=0.5f)
Gray predefined color.
Definition: Color.h:109
The namespace for gf classes.
Definition: Action.h:34
Predefined colors.
Definition: Color.h:44
A blue and light gray style.
static constexpr Color4f Opaque(float value=0.5f)
Opaque predefined color.
Definition: Color.h:100
A light gray style.