code integration

This commit is contained in:
Sylvain Schneider
2026-07-04 21:17:38 +02:00
parent 8329318677
commit 888765ef6b
64 changed files with 52755 additions and 1 deletions

View File

@@ -0,0 +1,68 @@
#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<uint32_t>(a) << 24) |
(static_cast<uint32_t>(r) << 16) |
(static_cast<uint32_t>(g) << 8) |
static_cast<uint32_t>(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<float>(r) / 255.0f,
static_cast<float>(g) / 255.0f,
static_cast<float>(b) / 255.0f,
static_cast<float>(a) / 255.0f };
}
//--------------------------------------------------------------