From 71dbb53a60026e37983d67c71d718cc1b54c3d33 Mon Sep 17 00:00:00 2001 From: cignoni Date: Thu, 24 Jun 2004 07:55:50 +0000 Subject: [PATCH] Now color ramp can do reverse color ramp --- vcg/space/color4.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vcg/space/color4.h b/vcg/space/color4.h index 68158671..f887c67a 100644 --- a/vcg/space/color4.h +++ b/vcg/space/color4.h @@ -24,6 +24,9 @@ History $Log: not supported by cvs2svn $ +Revision 1.6 2004/05/26 15:10:29 cignoni +Corrected bug in setgrayshade + Revision 1.5 2004/05/07 12:46:55 cignoni added ifdef for gcc [Bug c++/14479] @@ -103,6 +106,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 SetRGB( unsigned char r, unsigned char g, unsigned char b ) @@ -209,6 +213,7 @@ inline void Color4::lerp(const Color4 &c0, const Color4 &c1, const Colo template inline void Color4::ColorRamp(const float &minf,const float &maxf ,float v ) { + if(minf>maxf) { ColorRamp(maxf,minf,maxf+(minf-v)); return; } if(v < minf ) { *this=Color4(Color4::Red); return; } float step=(maxf-minf)/4;