Gamedev Framework (gf)  0.8.0
A C++14 framework for 2D games
Color.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 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 
176  static Color4f fromRgbF(float r, float g, float b) {
177  return Color4f(r, g, b, 1.0f);
178  }
179 
189  static Color4f fromRgba32(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
190 
197  static Color4f fromRgba32(uint32_t color);
198 
205  static Color4f fromRgba32(Color4u color);
206 
213  static Color4u toRgba32(Color4f color);
214 
215  };
216 
217 #ifndef DOXYGEN_SHOULD_SKIP_THIS
218 }
219 #endif
220 }
221 
222 #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.
Vector< float, 4 > Color4f
A float color vector with 4 components.
Definition: Vector.h:1259
static constexpr Color4f Opaque(float value=0.5f)
Opaque predefined color.
Definition: Color.h:100
A light gray style.
static Color4f fromRgbF(float r, float g, float b)
Get an opaque color from 3 RGB floats in .
Definition: Color.h:176
The cell is transparent.