diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2014-04-08 05:17:27 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2014-04-08 05:17:27 +0200 |
commit | ac164afa0954e28b521dc6b19d2ccf0320cc8ed1 (patch) | |
tree | 576420091adcad7b91dc1c8b296cc36b3d827b74 /src/utils/color/rgba.cpp | |
parent | 196f41688d01b7f0a79567c617fd6dd3171150ff (diff) | |
download | usdx-ac164afa0954e28b521dc6b19d2ccf0320cc8ed1.tar.gz usdx-ac164afa0954e28b521dc6b19d2ccf0320cc8ed1.tar.xz usdx-ac164afa0954e28b521dc6b19d2ccf0320cc8ed1.zip |
utils/colors: move colors into subdir, add hsv
All color classes are now in an own subdirectory with a short name.
The new class HsvColor represents the Hue/Saturation/Value color model and
comes with conversion functions to and from rgb colors (currently integer
arithmetic without optimization for higher presicion).
Diffstat (limited to '')
-rw-r--r-- | src/utils/color/rgba.cpp (renamed from src/utils/rgba_color.cpp) | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/utils/rgba_color.cpp b/src/utils/color/rgba.cpp index aed484f6..777bb720 100644 --- a/src/utils/rgba_color.cpp +++ b/src/utils/color/rgba.cpp @@ -24,16 +24,11 @@ #include <cstddef> -#include "rgba_color.hpp" +#include "rgba.hpp" namespace usdx { - RgbaColor::RgbaColor(int red, int green, int blue, int alpha) - : RgbColor(red, green, blue), alpha(alpha/255.0f) - { - } - - RgbaColor::RgbaColor(float red, float green, float blue, float alpha) + RgbaColor::RgbaColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) : RgbColor(red, green, blue), alpha(alpha) { } @@ -43,12 +38,7 @@ namespace usdx { } - RgbaColor::RgbaColor(const RgbColor& color, int alpha) - : RgbColor(color), alpha(alpha / 255.0f) - { - } - - RgbaColor::RgbaColor(const RgbColor& color, float alpha) + RgbaColor::RgbaColor(const RgbColor& color, uint8_t alpha) : RgbColor(color), alpha(alpha) { } @@ -73,7 +63,7 @@ namespace usdx return *this; } - float RgbaColor::get_alpha(void) const + uint8_t RgbaColor::get_alpha(void) const { return alpha; } @@ -92,10 +82,10 @@ namespace usdx array_length = len; for (size_t i = 0; i < len; i++) { - array[i*components] = get_red() * 255.0f; - array[(i*components) + 1] = get_green() * 255.0f; - array[(i*components) + 2] = get_blue() * 255.0f; - array[(i*components) + 3] = alpha * 255.0f; + array[i*components] = get_red(); + array[(i*components) + 1] = get_green(); + array[(i*components) + 2] = get_blue(); + array[(i*components) + 3] = alpha; } } |