#include "Colors.h" using namespace quokka_gfx; //-------------------------------------------------------------- const Color Color::Black{ 0, 0, 0, 255 }; const Color Color::White{ 255, 255, 255, 255 }; const Color Color::Red{ 255, 0, 0, 255 }; const Color Color::Green{ 0, 255, 0, 255 }; const Color Color::Blue{ 0, 0, 255, 255 }; const Color Color::Yellow{ 255, 255, 0, 255 }; const Color Color::Magenta{ 255, 0, 255, 255 }; const Color Color::Cyan{ 0, 255, 255, 255 }; const Color Color::Transparent{ 0, 0, 0, 0 }; //-------------------------------------------------------------- /* Constructor */ constexpr Color::Color(const uint8_t red, const uint8_t green, const uint8_t blue, const uint8_t alpha) : r(red) , g(green) , b(blue) , a(alpha) { } //-------------------------------------------------------------- /* Constructor */ constexpr Color::Color(const uint32_t hexColor) : r((hexColor >> 16) & 0xFF) , g((hexColor >> 8) & 0xFF) , b(hexColor & 0xFF) , a((hexColor >> 24) & 0xFF ? (hexColor >> 24) & 0xFF : 255) { } //-------------------------------------------------------------- /* Convert Color to SDL_Color */ constexpr Color::operator SDL_Color() const { return toSDL_Color(); } //-------------------------------------------------------------- /* Convert Color to SDL_FColor */ constexpr Color::operator SDL_FColor() const { return toSDL_FColor(); } //-------------------------------------------------------------- /* Convert Color to hex representation */ constexpr uint32_t Color::toHex() const { return (static_cast(a) << 24) | (static_cast(r) << 16) | (static_cast(g) << 8) | static_cast(b); } //-------------------------------------------------------------- /* Convert Color to SDL_Color */ constexpr SDL_Color Color::toSDL_Color() const { return SDL_Color{ r, g, b, a }; } //-------------------------------------------------------------- /* Convert Color to SDL_FColor */ constexpr SDL_FColor Color::toSDL_FColor() const { return SDL_FColor{ static_cast(r) / 255.0f, static_cast(g) / 255.0f, static_cast(b) / 255.0f, static_cast(a) / 255.0f }; } //--------------------------------------------------------------