summaryrefslogtreecommitdiff
path: root/src/helpers/Color.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-01-05 19:25:45 +0100
committervaxerski <vaxry@vaxry.net>2023-01-05 19:25:45 +0100
commit96198dae55b1429449504e49065a10763b288431 (patch)
treeee18d707952df6fcbd4f9295e138d1571b64267b /src/helpers/Color.cpp
parent0e3547e0f6b4016aa308292a86c43cd47dd206fd (diff)
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.
Diffstat (limited to 'src/helpers/Color.cpp')
-rw-r--r--src/helpers/Color.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/helpers/Color.cpp b/src/helpers/Color.cpp
index c92f74ae..788d7bdf 100644
--- a/src/helpers/Color.cpp
+++ b/src/helpers/Color.cpp
@@ -4,6 +4,7 @@
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;
@@ -11,10 +12,10 @@ CColor::CColor(float r, float g, float b, float a) {
}
CColor::CColor(uint64_t hex) {
- this->r = RED(hex) * 255.f;
- this->g = GREEN(hex) * 255.f;
- this->b = BLUE(hex) * 255.f;
- this->a = ALPHA(hex) * 255.f;
+ this->r = RED(hex);
+ this->g = GREEN(hex);
+ this->b = BLUE(hex);
+ this->a = ALPHA(hex);
}
uint64_t CColor::getAsHex() {