From 96198dae55b1429449504e49065a10763b288431 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 5 Jan 2023 19:25:45 +0100 Subject: 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. --- src/helpers/Color.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/helpers/Color.cpp') 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() { -- cgit v1.2.3