ROOT logo
ROOT » CORE » BASE » TAttFill

class TAttFill


Fill Area Attributes class

This class is used (in general by secondary inheritance) by many other classes (graphics, histograms). It holds all the fill area attributes.

Fill Area attributes

Fill Area attributes are:

Fill Area color

The fill area color is a color index (integer) pointing in the ROOT color table. The fill area color of any class inheriting from TAttFill can be changed using the method SetFillColor and retrieved using the method GetFillColor. The following table shows the first 50 default colors.
output of MACRO_TAttFill_1_c
{
   TCanvas *c = new TCanvas("c","Fill Area colors",0,0,500,200);
   c.DrawColorTable();
   return c;
}

The ROOT Color Wheel.

The wheel contains the recommended 216 colors to be used in web applications. The colors in the Color Wheel are created by TColor::CreateColorWheel.

Using this color set for your text, background or graphics will give your application a consistent appearance across different platforms and browsers.

Colors are grouped by hue, the aspect most important in human perception Touching color chips have the same hue, but with different brightness and vividness.

Colors of slightly different hues clash. If you intend to display colors of the same hue together, you should pick them from the same group.

Each color chip is identified by a mnemonic (eg kYellow) and a number. The keywords, kRed, kBlue, kYellow, kPink, etc are defined in the header file Rtypes.h that is included in all ROOT other header files. We strongly recommend to use these keywords in your code instead of hardcoded color numbers, eg:

   myObject.SetFillColor(kRed);
   myObject.SetFillColor(kYellow-10);
   myLine.SetLineColor(kMagenta+2);
output of MACRO_TAttFill_3_wheel
{
   TColorWheel *w = new TColorWheel();
   w->Draw();
   return w->GetCanvas();
}

Special case forcing black&white output.

If the current style fill area color is set to 0, then ROOT will force a black&white output for all objects with a fill area defined and independently of the object fill style.

Fill Area style

The fill area style defines the pattern used to fill a polygon. The fill area style of any class inheriting from TAttFill can be changed using the method SetFillStyle and retrieved using the method GetFillStyle.

Conventions for fill styles:

  • 0 : hollow
  • 1001 : Solid
  • 3000+pattern_number (see below)
  • For TPad only:
    • 4000 :the window is transparent.
    • 4000 to 4100 the window is 100% transparent to 100% opaque.
    The pad transparency is visible in binary outputs files like gif, jpg, png etc .. but not in vector graphics output files like PS, PDF and SVG.
pattern_number can have any value from 1 to 25 (see table), or any value from 100 to 999. For the latest the numbering convention is the following:
      pattern_number = ijk      (FillStyle = 3ijk)
 
      i (1-9) : specify the space between each hatch
                1 = 1/2mm  9 = 6mm
 
      j (0-9) : specify angle between 0 and 90 degrees
                0 = 0
                1 = 10
                2 = 20
                3 = 30
                4 = 45
                5 = Not drawn
                6 = 60
                7 = 70
                8 = 80
                9 = 90
  
      k (0-9) : specify angle between 90 and 180 degrees
                0 = 180
                1 = 170
                2 = 160
                3 = 150
                4 = 135
                5 = Not drawn
                6 = 120
                7 = 110
                8 = 100
                9 = 90
The following table shows the list of pattern styles. The first table displays the 25 fixed patterns. They cannot be customized unlike the hatches displayed in the second table which be customized using:
  • gStyle->SetHatchesSpacing() to define the spacing between hatches.
  • gStyle->SetHatchesLineWidth() to define the hatches line width.
output of MACRO_TAttFill_5_Fill_Patterns
TCanvas * fillpatterns()
{
   // Fill patterns example. This macro shows the available fill patterns.
   // The first table displays the 25 fixed patterns. They cannot be
   // customized unlike the hatches displayed in the second table which be 
   // cutomized using:
   //   - gStyle->SetHatchesSpacing() to define the spacing between hatches.
   SetHatchesLineWidth() to define the hatches line width.
   
   
      
   TCanvas *Pat = new TCanvas("Fill Patterns", "",0,0,500,700);
   Pat->Range(0,0,1,1);
   Pat->SetBorderSize(2);
   Pat->SetFrameFillColor(0);
   Double_t bh = 0.059;
   Double_t db = 0.01; 
   Double_t y  = 0.995;
   Int_t i,j=3001;

   
   for (i=1; i<=5; i++) {
      box(j++, 0.01, y-bh, 0.19, y);
      box(j++, 0.21, y-bh, 0.39, y);
      box(j++, 0.41, y-bh, 0.59, y);
      box(j++, 0.61, y-bh, 0.79, y);
      box(j++, 0.81, y-bh, 0.99, y);
      y = y-bh-db;
   }

   
   y = y-3*db;
   gStyle->SetHatchesSpacing(2.0);
   gStyle->SetHatchesLineWidth(1);
   Int_t j1 = 3144;
   Int_t j2 = 3305;
   Int_t j3 = 3350;
   Int_t j4 = 3490;
   Int_t j5 = 3609;
   for (i=1; i<=9; i++) {
      if (i==6) {j2 += 10; j3 += 1; j4 += 1; j5 += 10;}
      if (i==5) {j4 -= 10; j5 -= 1;}
      box(j1, 0.01, y-bh, 0.19, y);
      box(j2, 0.21, y-bh, 0.39, y);
      box(j3, 0.41, y-bh, 0.59, y);
      box(j4, 0.61, y-bh, 0.79, y);
      box(j5, 0.81, y-bh, 0.99, y);
      j1 += 100;
      j2 += 10;
      j3 += 1;
      j4 -= 9;
      j5 += 9;
      y = y-bh-db;
   }
   return Pat;
}

box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t  y2)
{
   "pat" with the "pat" value
   

   TBox b;
   b.SetFillColor(1);
   b.SetFillStyle(pat); b.DrawBox(x1,y1,x2,y2);
   b.SetFillStyle(0)  ; b.DrawBox(x1,y1,x2,y2);
   b.SetFillColor(0)  ; b.SetFillStyle(1000)  ;
   Double_t dx = (x2-x1)/3;
   Double_t dy = (y2-y1)/3;
   Double_t h  = (y2-y1)/2.5;
   b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy);
   b.SetFillStyle(0);
   b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy);

   TLatex l;
   l.SetTextAlign(22); l.SetTextSize(h);
   l.DrawLatex((x1+x2)/2, (y1+y2)/2, Form("%d",pat));
}
 

Function Members (Methods)

public:
TAttFill()
TAttFill(const TAttFill&)
TAttFill(Color_t fcolor, Style_t fstyle)
virtual~TAttFill()
static TClass*Class()
voidCopy(TAttFill& attfill) const
virtual Color_tGetFillColor() const
virtual Style_tGetFillStyle() const
virtual TClass*IsA() const
virtual Bool_tIsTransparent() const
virtual voidModify()
TAttFill&operator=(const TAttFill&)
virtual voidResetAttFill(Option_t* option = "")
virtual voidSaveFillAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1001)
virtual voidSetFillAttributes()MENU
virtual voidSetFillColor(Color_t fcolor)
virtual voidSetFillStyle(Style_t fstyle)
virtual voidShowMembers(TMemberInspector& insp)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)

Data Members

protected:
Color_tfFillColorfill area color
Style_tfFillStylefill area style

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TAttFill()
 AttFill default constructor.
 Default fill attributes are taking from the current style
TAttFill(Color_t fcolor, Style_t fstyle)
 AttFill normal constructor.
 color Fill Color
 style Fill Style
~TAttFill()
 AttFill destructor.
void Copy(TAttFill& attfill) const
 Copy this fill attributes to a new TAttFill.
void Modify()
 Change current fill area attributes if necessary.
void ResetAttFill(Option_t* option = "")
 Reset this fill attributes to default values.
void SaveFillAttributes(ostream& out, const char* name, Int_t coldef = 1, Int_t stydef = 1001)
 Save fill attributes as C++ statement(s) on output stream out
void SetFillAttributes()
 Invoke the DialogCanvas Fill attributes.
Bool_t IsTransparent() const
{ return fFillStyle >= 4000 && fFillStyle <= 4100 ? kTRUE : kFALSE; }
TAttFill()
Color_t GetFillColor() const
{ return fFillColor; }
Style_t GetFillStyle() const
{ return fFillStyle; }
void SetFillColor(Color_t fcolor)
{ fFillColor = fcolor; }
void SetFillStyle(Style_t fstyle)
{ fFillStyle = fstyle; }