Hyprland/src/helpers/Color.cpp
vaxerski 96198dae55 Normalize color storage
Colors are now normalized to 0 - 1 values instead of 0 - 255

causes calculations to be simpler and generally cleans up the codebase.
2023-01-05 19:25:45 +01:00

23 lines
No EOL
542 B
C++

#include "Color.hpp"
#include "../defines.hpp"
CColor::CColor() {}
CColor::CColor(float r, float g, float b, float a) {
RASSERT(r <= 1.f && g <= 1.f && b <= 1.f && a <= 1.f, "un-normalized color assignment");
this->r = r;
this->g = g;
this->b = b;
this->a = a;
}
CColor::CColor(uint64_t hex) {
this->r = RED(hex);
this->g = GREEN(hex);
this->b = BLUE(hex);
this->a = ALPHA(hex);
}
uint64_t CColor::getAsHex() {
return ((int)a) * 0x1000000 + ((int)r) * 0x10000 + ((int)g) * 0x100 + ((int)b) * 0x1;
}