-/**************************************************************************/
-// RGBAPalette
-/**************************************************************************/
-
-RGBAPalette::RGBAPalette() :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (kFALSE),
- fWrap (kFALSE),
- fColorArray (0)
-{
- SetMinMax(0, 100);
-}
-
-RGBAPalette::RGBAPalette(Int_t min, Int_t max) :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (kFALSE),
- fWrap (kFALSE),
- fColorArray (0)
-{
- SetMinMax(min, max);
-}
-
-RGBAPalette::RGBAPalette(Int_t min, Int_t max, Bool_t interp, Bool_t wrap) :
- TObject(),
- Reve::ReferenceCount(),
- fInterpolate (interp),
- fWrap (wrap),
- fColorArray (0)
-{
- SetMinMax(min, max);
-}
-
-RGBAPalette::~RGBAPalette()
-{
- delete [] fColorArray;
-}
-
-/**************************************************************************/
-
-void RGBAPalette::SetupColor(Int_t val, UChar_t* pixel) const
-{
- using namespace TMath;
- Float_t div = Max(1, fMaxVal - fMinVal);
- Int_t nCol = gStyle->GetNumberOfColors();
-
- Float_t f;
- if (val <= fMinVal) f = 0;
- else if (val >= fMaxVal) f = nCol - 1;
- else f = (val - fMinVal)/div*(nCol - 1);
-
- if (fInterpolate) {
- Int_t bin = (Int_t) f;
- Float_t f1 = f - bin, f2 = 1.0f - f1;
- ColorFromIdx(f1, gStyle->GetColorPalette(bin),
- f2, gStyle->GetColorPalette(Min(bin + 1, nCol - 1)),
- pixel);
- } else {
- ColorFromIdx(gStyle->GetColorPalette((Int_t) Nint(f)), pixel);
- }
-}
-
-void RGBAPalette::SetupColorArray() const
-{
- if(fColorArray)
- return;
-
- fColorArray = new UChar_t [4 * fNBins];
- UChar_t* p = fColorArray;
- for(Int_t v=fMinVal; v<=fMaxVal; ++v, p+=4)
- SetupColor(v, p);
-}
-
-void RGBAPalette::ClearColorArray()
-{
- if(fColorArray) {
- delete [] fColorArray;
- fColorArray = 0;
- }
-}
-
-/**************************************************************************/
-
-void RGBAPalette::SetMinMax(Int_t min, Int_t max)
-{
- fMinVal = min;
- fMaxVal = max;
- fNBins = max - min + 1;
- ClearColorArray();
-}
-
-void RGBAPalette::SetInterpolate(Bool_t b)
-{
- fInterpolate = b;
- ClearColorArray();
-}
-
-void RGBAPalette::SetWrap(Bool_t b)
-{
- fWrap = b;
-}