#include <ColorScale.h>
Public Member Functions | |
| ColorScale (double xlo, double xhi, int which=kRainbow, int scale=kLinear, int n=40, double h1=0, double h1=0, double v1=0, double v2=0) | |
| int | operator() (double x) const |
| int | GetColor (double x) const |
| void | SetPalette () |
Private Member Functions | |
| void | HSVtoRGB (double h, double s, double v, double *r, double *g, double *b) const |
| void | MakeHSVScale (int n, double h1, double h2, double vs1, double vs2) |
| Make a color scale of n colors ranging between two points in an HSV color space. | |
Private Attributes | |
| double | fXlo |
| double | fXhi |
| Numeric value at low end of scale. | |
| int | fScale |
| Numeric value at high end of scale. | |
| int | fNcolor |
| Linear? Log? Sqrt? | |
| int | fColors [128] |
| How many colors in scale? | |
Definition at line 34 of file ColorScale.h.
|
||||||||||||||||||||||||||||||||||||||||
|
Construct a color scale
Definition at line 28 of file ColorScale.cxx. References evd::kBlues, evd::kColdToHot, evd::kCustom, evd::kGeographic, evd::kGreens, evd::kHeatedObject, evd::kRainbow, evd::kReds, and MakeHSVScale().
00030 : 00031 fXlo(xlo), 00032 fXhi(xhi), 00033 fScale(scale) 00034 { 00035 switch(which) { 00036 case kColdToHot: this->MakeHSVScale(n, 150.0, 0.0, 0.2, 0.5); break; 00037 case kHeatedObject: this->MakeHSVScale(n, 60.0, 0.0, 0.1, 0.9); break; 00038 case kReds: this->MakeHSVScale(n, 30.0, 0.0, 0.1, 0.9); break; 00039 case kBlues: this->MakeHSVScale(n, 180.0, 270.0, 0.1, 0.9); break; 00040 case kGreens: this->MakeHSVScale(n, 90.0, 120.0, 0.1, 0.9); break; 00041 case kGeographic: this->MakeHSVScale(n, 270.0, 30.0, 0.9, 0.05); break; 00042 case kCustom: this->MakeHSVScale(n, h1, h2, v1, v2); break; 00043 case kRainbow: 00044 // Default to a rainbow. 00045 default: 00046 this->MakeHSVScale(16,270,0,0.1,0.6); 00047 break; 00048 } 00049 } |
|
|
Assign a ROOT color index to the value x
Definition at line 58 of file ColorScale.cxx. References fColors, fNcolor, fScale, fXhi, fXlo, evd::kLinear, evd::kLog, and evd::kSqrt. Referenced by evd::Display3D::DrawRawData(), and operator()().
00059 {
00060 double f=0.0;
00061 if (fScale == kLinear) {
00062 f = (x-fXlo)/(fXhi-fXlo);
00063 }
00064 else if (fScale == kLog) {
00065 f = (log(x)-log(fXlo))/(log(fXhi)-log(fXlo));
00066 }
00067 else if (fScale == kSqrt) {
00068 f = (sqrt(x)-sqrt(fXlo))/(sqrt(fXhi)-sqrt(fXlo));
00069 }
00070
00071 int indx = (int)floor(f*(float)fNcolor);
00072 if (indx<0) indx = 0;
00073 if (indx>=fNcolor) indx = fNcolor-1;
00074 return fColors[indx];
00075 }
|
|
||||||||||||||||||||||||||||
|
Convert hue, saturation and value numbers to red, green, blue
Definition at line 91 of file ColorScale.cxx. Referenced by MakeHSVScale().
00093 {
00094 // A-chromatic, return grey scale values
00095 if (s==0.0) { *r = *g = *b = v; return; }
00096
00097 int i;
00098 double f, p, q, t;
00099 double hh = h;
00100 while (hh< 0.0) hh += 360.0;
00101 while (hh>360.0) hh -= 360.0;
00102 hh /= 60;
00103 i = (int)floor(hh);
00104 f = hh - i;
00105 p = v * (1 - s);
00106 q = v * (1 - s*f);
00107 t = v * (1 - s*(1-f) );
00108 switch( i ) {
00109 case 0: *r = v; *g = t; *b = p; break;
00110 case 1: *r = q; *g = v; *b = p; break;
00111 case 2: *r = p; *g = v; *b = t; break;
00112 case 3: *r = p; *g = q; *b = v; break;
00113 case 4: *r = t; *g = p; *b = v; break;
00114 default: *r = v; *g = p; *b = q; break;
00115 }
00116 }
|
|
||||||||||||||||||||||||
|
Make a color scale of n colors ranging between two points in an HSV color space. Choose points so that the value of the colors changes uniformly. This ensures good viewing event in black and white.
Definition at line 132 of file ColorScale.cxx. References fColors, fNcolor, and HSVtoRGB(). Referenced by ColorScale().
00135 {
00136 int i;
00137 double r, g, b;
00138 double h;
00139 double vs, v, s;
00140
00141 if (n>128) n = 128;
00142 fNcolor = n;
00143
00144 for (i=0; i<fNcolor; ++i) {
00145 h = h1 + (h2-h1)*(float)i/(float)(fNcolor-1);
00146 vs = vs1 + (vs2-vs1)*(float)i/(float)(fNcolor-1);
00147 vs = -1.0 + 2.0*vs;
00148 if (vs<0.0) { v = 1.0; s = 1.0+vs; }
00149 else { v = 1.0-vs; s = 1.0; }
00150 this->HSVtoRGB(h, s, v, &r, &g, &b);
00151 r *= 255;
00152 g *= 255;
00153 b *= 255;
00154 fColors[i] = TColor::GetColor((int)r,(int)g,(int)b);
00155 }
00156 }
|
|
|
Definition at line 76 of file ColorScale.cxx. References GetColor().
00076 {
00077 return this->GetColor(x);
00078 }
|
|
|
Set the ROOT color palette to use this color scale Definition at line 162 of file ColorScale.cxx. References fColors, and fNcolor.
00163 {
00164 gStyle->SetPalette(fNcolor, fColors);
00165 }
|
|
|
How many colors in scale?
Definition at line 57 of file ColorScale.h. Referenced by GetColor(), MakeHSVScale(), and SetPalette(). |
|
|
Linear? Log? Sqrt?
Definition at line 56 of file ColorScale.h. Referenced by GetColor(), MakeHSVScale(), and SetPalette(). |
|
|
Numeric value at high end of scale.
Definition at line 55 of file ColorScale.h. Referenced by GetColor(). |
|
|
Numeric value at low end of scale.
Definition at line 54 of file ColorScale.h. Referenced by GetColor(). |
|
|
Definition at line 53 of file ColorScale.h. Referenced by GetColor(). |
1.3.5