#ifndef ROOT_TColorGradient
#define ROOT_TColorGradient
#include <vector>
#ifndef ROOT_Rtypes
#include "Rtypes.h"
#endif
#ifndef ROOT_TColor
#include "TColor.h"
#endif
class TColorGradient : public TColor {
public:
typedef std::vector<Color_t>::size_type SizeType_t;
enum ECoordinateMode {
kPadMode,
kObjectBoundingMode
};
struct Point {
Double_t fX;
Double_t fY;
Point()
: fX(0.), fY(0.)
{
}
Point(Double_t x, Double_t y)
: fX(x), fY(y)
{
}
};
private:
std::vector<Double_t> fColorPositions;
std::vector<Double_t> fColors;
ECoordinateMode fCoordinateMode;
protected:
TColorGradient();
TColorGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Color_t *colorIndices, ECoordinateMode mode = kObjectBoundingMode);
TColorGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Double_t *colors, ECoordinateMode mode = kObjectBoundingMode);
public:
void ResetColor(UInt_t nPoints, const Double_t *points,
const Color_t *colorIndices);
void ResetColor(UInt_t nPoints, const Double_t *points,
const Double_t *colorIndices);
void SetCoordinateMode(ECoordinateMode mode);
ECoordinateMode GetCoordinateMode()const;
SizeType_t GetNumberOfSteps()const;
const Double_t *GetColorPositions()const;
const Double_t *GetColors()const;
private:
void RegisterColor(Color_t colorIndex);
ClassDef(TColorGradient, 1)
};
class TLinearGradient : public TColorGradient {
public:
TLinearGradient();
TLinearGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Color_t *colorIndices, ECoordinateMode mode = kObjectBoundingMode);
TLinearGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Double_t *colors, ECoordinateMode mode = kObjectBoundingMode);
void SetStartEnd(const Point &p1, const Point &p2);
const Point &GetStart()const;
const Point &GetEnd()const;
private:
Point fStart;
Point fEnd;
ClassDef(TLinearGradient, 1)
};
class TRadialGradient : public TColorGradient {
public:
enum EGradientType {
kSimple,
kExtended
};
TRadialGradient();
TRadialGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Color_t *colorIndices, ECoordinateMode mode = kObjectBoundingMode);
TRadialGradient(Color_t newColor, UInt_t nPoints, const Double_t *points,
const Double_t *colors, ECoordinateMode mode = kObjectBoundingMode);
EGradientType GetGradientType()const;
void SetStartEndR1R2(const Point &p1, Double_t r1,
const Point &p2, Double_t r2);
const Point &GetStart()const;
Double_t GetR1()const;
const Point &GetEnd()const;
Double_t GetR2()const;
void SetRadialGradient(const Point ¢er, Double_t radius);
const Point &GetCenter()const;
Double_t GetRadius()const;
private:
Point fStart;
Double_t fR1;
Point fEnd;
Double_t fR2;
EGradientType fType;
ClassDef(TRadialGradient, 1)
};
#endif