2022-03-31 17:50:00 +02:00
|
|
|
#include "Color.hpp"
|
2023-08-07 13:35:19 +02:00
|
|
|
|
|
|
|
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
|
|
|
|
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
|
|
|
|
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
|
|
|
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
2022-03-31 17:50:00 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
CColor::CColor() {}
|
2022-03-31 17:50:00 +02:00
|
|
|
|
|
|
|
CColor::CColor(float r, float g, float b, float a) {
|
|
|
|
this->r = r;
|
|
|
|
this->g = g;
|
|
|
|
this->b = b;
|
|
|
|
this->a = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
CColor::CColor(uint64_t hex) {
|
2023-01-05 19:25:45 +01:00
|
|
|
this->r = RED(hex);
|
|
|
|
this->g = GREEN(hex);
|
|
|
|
this->b = BLUE(hex);
|
|
|
|
this->a = ALPHA(hex);
|
2022-03-31 17:50:00 +02:00
|
|
|
}
|
|
|
|
|
2024-08-17 18:33:16 +02:00
|
|
|
uint32_t CColor::getAsHex() const {
|
2024-04-05 22:23:06 +02:00
|
|
|
return (uint32_t)(a * 255.f) * 0x1000000 + (uint32_t)(r * 255.f) * 0x10000 + (uint32_t)(g * 255.f) * 0x100 + (uint32_t)(b * 255.f) * 0x1;
|
2022-03-31 17:50:00 +02:00
|
|
|
}
|