From 8eb94a7f9d8b792d4934df133d906e2af8da7ada Mon Sep 17 00:00:00 2001 From: cignoni Date: Wed, 18 Apr 2012 21:17:04 +0000 Subject: [PATCH] Changed ColorRamp non static method into a static one (that constructs a Color4b object) and added a more uniform SetColorRamp method. --- vcg/space/color4.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vcg/space/color4.h b/vcg/space/color4.h index 3008b0ae..a9b0087c 100644 --- a/vcg/space/color4.h +++ b/vcg/space/color4.h @@ -166,8 +166,7 @@ public: inline void lerp(const Color4 &c0, const Color4 &c1, const float x); inline void lerp(const Color4 &c0, const Color4 &c1, const Color4 &c2, const Point3f &ip); /// given a float and a range set the corresponding color in the well known red->green->blue color ramp. To reverse the direction of the ramp just swap minf and maxf. - inline void ColorRamp(const float &minf,const float &maxf ,float v ); - + inline void SetColorRamp(const float &minf,const float &maxf ,float v ); inline void SetRGB( unsigned char r, unsigned char g, unsigned char b ) { (*this)[0] = r; @@ -249,6 +248,12 @@ inline static Color4 Scatter(int range, int value,float Sat=.3f,float Val=.9f) return rc; } +inline static Color4 ColorRamp(const float &minf,const float &maxf ,float v ) +{ + Color4 rc; + rc.SetColorRamp(minf,maxf,v); + return rc; +} }; template inline void Color4::lerp(const Color4 &c0, const Color4 &c1, const float x) @@ -273,11 +278,10 @@ inline void Color4::lerp(const Color4 &c0, const Color4 &c1, const Colo (*this)[3]=(T)(c0[3]*ip[0] + c1[3]*ip[1]+ c2[3]*ip[2]); } - template -inline void Color4::ColorRamp(const float &minf,const float &maxf ,float v ) +inline void Color4::SetColorRamp(const float &minf,const float &maxf ,float v ) { - if(minf>maxf) { ColorRamp(maxf,minf,maxf+(minf-v)); return; } + if(minf>maxf) { SetColorRamp(maxf,minf,maxf+(minf-v)); return; } if(v < minf ) { *this=Color4(Color4::Red); return; } //the case v > maxf is handled automatically at the end of the function