9 #ifndef TurtleBrains_Color_hpp
10 #define TurtleBrains_Color_hpp
12 #include <turtle_brains/core/tb_types.hpp>
13 #include <turtle_brains/core/tb_dynamic_structure.hpp>
14 #include <turtle_brains/math/tb_math.hpp>
29 constexpr
Color(
void) noexcept :
43 mAlpha(
static_cast<float>((colorARGB >> 24) & 0xFF) / 255.0f),
44 mRed(
static_cast<float>((colorARGB >> 16) & 0xFF) / 255.0f),
45 mGreen(
static_cast<float>((colorARGB >> 8) & 0xFF) / 255.0f),
46 mBlue(
static_cast<float>((colorARGB) & 0xFF) / 255.0f),
62 constexpr
explicit Color(
const float clampedAlpha,
const float clampedRed,
const float clampedGreen,
const float clampedBlue) noexcept :
63 mAlpha(tbMath::Clamp(clampedAlpha, 0.0f, 1.0f)),
64 mRed(tbMath::Clamp(clampedRed, 0.0f, 1.0f)),
65 mGreen(tbMath::Clamp(clampedGreen, 0.0f, 1.0f)),
66 mBlue(tbMath::Clamp(clampedBlue, 0.0f, 1.0f)),
100 void SetColor(
const float clampedAlpha,
const float clampedRed,
const float clampedGreen,
const float clampedBlue);
149 void SetAlpha(
const float alpha);
150 void SetAlpha(
const int alpha);
157 void SetRed(
const float red);
158 void SetRed(
const int red);
165 void SetGreen(
const float green);
166 void SetGreen(
const int green);
173 void SetBlue(
const float blue);
174 void SetBlue(
const int blue);
186 namespace Implementation {
Color RampedColor(
const Color& color500,
const float rampValue); };
188 namespace ColorPalette
190 template<const Color& baseColor,
int lightness = 500>
Color Lightness =
191 Implementation::RampedColor(baseColor,
static_cast<float>(lightness) / 1000.0f);
193 template<const Color& baseColor>
Color Lighter = Lightness<baseColor, 100>;
194 template<const Color& baseColor>
Color Light = Lightness<baseColor, 300>;
195 template<const Color& baseColor>
Color Dark = Lightness<baseColor, 700>;
196 template<const Color& baseColor>
Color Darker = Lightness<baseColor, 900>;
198 constexpr
Color Opaque(0xFFFFFFFF);
199 constexpr
Color Transparent(0x00FFFFFF);
201 constexpr
Color Black(0xFF000000);
202 constexpr
Color White(0xFFFFFFFF);
203 constexpr
Color Magenta(0xFFFF00FF);
205 #define tb_make_color(name, rgb) \
206 constexpr Color name(0xFF000000 | rgb); \
207 inline const Color Light##name = Light<name>; \
208 inline const Color Lighter##name = Lighter<name>; \
209 inline const Color Dark##name = Dark<name>; \
210 inline const Color Darker##name = Darker<name>;
212 tb_make_color(Purple, 0xFF6F42C1);
213 tb_make_color(Indigo, 0xFF6610F2);
214 tb_make_color(Blue, 0xFF0D6EFD);
215 tb_make_color(Cyan, 0xFF0DCAF0);
216 tb_make_color(Teal, 0xFF20C997);
217 tb_make_color(Green, 0xFF198754);
218 tb_make_color(Yellow, 0xFFFFC107);
219 tb_make_color(Orange, 0xFFFD7E14);
220 tb_make_color(Pink, 0xFFD63384);
221 tb_make_color(Red, 0xFFDC3545);
222 tb_make_color(Gray, 0xFFADB5BD);
253 using Color = Graphics::Color;
254 namespace ColorPalette = Graphics::ColorPalette;
256 template<>
inline DynamicStructure ToDynamicStructure<Graphics::Color>(
const Graphics::Color& color)
263 template<>
inline Graphics::Color FromDynamicStructure<Graphics::Color>(
const DynamicStructure& data)
266 return Graphics::Color();
276 namespace ColorPalette
Definition: tb_dynamic_structure.hpp:95
Definition: tb_color.hpp:24
void SetColor(const tbCore::uint32 &colorARGB)
tbCore::uint8 GetBlueByte(void) const
float GetGreen(void) const
tbCore::uint32 GetColorARGB(void) const
tbCore::uint8 GetGreenByte(void) const
tbCore::uint32 GetColorABGR(void) const
constexpr Color(const tbCore::uint32 &colorARGB) noexcept
Definition: tb_color.hpp:42
constexpr Color(const float clampedAlpha, const float clampedRed, const float clampedGreen, const float clampedBlue) noexcept
Definition: tb_color.hpp:62
void SetColor(const float clampedAlpha, const float clampedRed, const float clampedGreen, const float clampedBlue)
float GetBlue(void) const
tbCore::uint8 GetRedByte(void) const
tbCore::uint8 GetAlphaByte(void) const
void SetColor(const float clampedTween, const Color &startColor, const Color &finalColor)
float GetAlpha(void) const
bool SetColor(const tbCore::DynamicStructure &colorData, bool triggerErrorOnFailure=true)
constexpr Color(void) noexcept
Definition: tb_color.hpp:29
#define tb_unused(parameter)
Definition: tb_defines.hpp:25
std::uint8_t uint8
Unsigned integer with a size of 8 bits. Supports values from 0 to 255.
Definition: tb_types.hpp:22
std::uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1).
Definition: tb_types.hpp:27
Give the GameScene and Entities something to display, Text, Sprites and AnimatedSprites help bring th...
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:22