51 #include <ACG/Utils/ColorCoder.hh> 70 val0_ = val1_ = val2_ = val3_ = val4_ = _min;
73 std::swap(_min, _max);
76 val2_ = 0.5 * (val0_ + val4_);
77 val1_ = 0.5 * (val0_ + val2_);
78 val3_ = 0.5 * (val2_ + val4_);
80 signed_mode_ = _signed;
86 return signed_mode_ ? color_signed(_v) : color_unsigned(_v);
93 return (
ACG::Vec4f(c[0], c[1], c[2], c[3]) / 255.f);
107 ACG::Vec4uc ColorCoder::color_unsigned(
float _v)
const 122 u = (
unsigned char) (255.0 * (_v - val0_) / (val1_ - val0_));
127 u = (
unsigned char) (255.0 * (_v - val1_) / (val2_ - val1_));
133 u = (
unsigned char) (255.0 * (_v - val2_) / (val3_ - val2_));
138 u = (
unsigned char) (255.0 * (_v - val3_) / (val4_ - val3_));
144 ACG::Vec4uc ColorCoder::color_signed(
float _v)
const 149 unsigned char r, g, b;
157 r = val0_ ? (
unsigned char) (255.0 * _v / val0_) : 0;
161 b = val4_ ? (
unsigned char) (255.0 * _v / val4_) : 0;
float min() const override
min scalar value
Namespace providing different geometric functions concerning angles.
ACG::Vec4uc color4_raw(float _v) const override
color coding
ColorCoder(float _min=0.0, float _max=1.0, bool _signed=false)
Default constructor.
float max() const override
max scalar value
void set_range(float _min, float _max, bool _signed)
set the color coding range for unsigned coding
ACG::Vec4f color_float4_raw(float _v) const override
color coding
VectorT< unsigned char, 4 > Vec4uc