Logo ROOT  
Reference Guide
fillpatterns.C
Go to the documentation of this file.
2{
3 // Draw an box using the fill pattern "pat" with the "pat" value
4 // written on top.
5
6 TBox b;
7 b.SetFillColor(1);
8 b.SetFillStyle(pat); b.DrawBox(x1,y1,x2,y2);
9 b.SetFillStyle(0) ; b.DrawBox(x1,y1,x2,y2);
10 b.SetFillColor(0) ; b.SetFillStyle(1000) ;
11 Double_t dx = (x2-x1)/3;
12 Double_t dy = (y2-y1)/3;
13 Double_t h = (y2-y1)/2.5;
14 b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy);
15 b.SetFillStyle(0);
16 b.DrawBox(x1+dx, y1+dy, x2-dx, y2-dy);
17
18 TLatex l;
19 l.SetTextAlign(22); l.SetTextSize(h);
20 l.DrawLatex((x1+x2)/2, (y1+y2)/2, Form("%d",pat));
21}
22
23TCanvas * fillpatterns(int w=500, int h=700)
24{
25 // Fill patterns example. This macro shows the available fill patterns.
26 // The first table displays the 25 fixed patterns. They cannot be
27 // customized unlike the hatches displayed in the second table which be
28 // cutomized using:
29 // - gStyle->SetHatchesSpacing() to define the spacing between hatches.
30 // - gStyle->SetHatchesLineWidth() to define the hatches line width.
31 //
32 // Author: Olivier Couet.
33
34 TCanvas *Pat = new TCanvas("Fill Patterns", "",0,0,w,h);
35 Pat->Range(0,0,1,1);
36 Pat->SetBorderSize(2);
37 Pat->SetFrameFillColor(0);
38 Double_t bh = 0.059;
39 Double_t db = 0.01;
40 Double_t y = 0.995;
41 Int_t i,j=3001;
42
43 // Fixed patterns.
44 for (i=1; i<=5; i++) {
45 box(j++, 0.01, y-bh, 0.19, y);
46 box(j++, 0.21, y-bh, 0.39, y);
47 box(j++, 0.41, y-bh, 0.59, y);
48 box(j++, 0.61, y-bh, 0.79, y);
49 box(j++, 0.81, y-bh, 0.99, y);
50 y = y-bh-db;
51 }
52
53 // Hatches
54 y = y-3*db;
57 Int_t j1 = 3144;
58 Int_t j2 = 3305;
59 Int_t j3 = 3350;
60 Int_t j4 = 3490;
61 Int_t j5 = 3609;
62 for (i=1; i<=9; i++) {
63 if (i==6) {j2 += 10; j3 += 1; j4 += 1; j5 += 10;}
64 if (i==5) {j4 -= 10; j5 -= 1;}
65 box(j1, 0.01, y-bh, 0.19, y);
66 box(j2, 0.21, y-bh, 0.39, y);
67 box(j3, 0.41, y-bh, 0.59, y);
68 box(j4, 0.61, y-bh, 0.79, y);
69 box(j5, 0.81, y-bh, 0.99, y);
70 j1 += 100;
71 j2 += 10;
72 j3 += 1;
73 j4 -= 9;
74 j5 += 9;
75 y = y-bh-db;
76 }
77 return Pat;
78}
#define b(i)
Definition: RSha256.hxx:100
#define h(i)
Definition: RSha256.hxx:106
static const double x2[5]
static const double x1[5]
int Int_t
Definition: RtypesCore.h:43
double Double_t
Definition: RtypesCore.h:57
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition: TStyle.h:410
void SetFrameFillColor(Color_t color=1)
Definition: TAttPad.h:73
Create a Box.
Definition: TBox.h:24
The Canvas class.
Definition: TCanvas.h:27
To draw Mathematical Formula.
Definition: TLatex.h:18
virtual void Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Set world coordinate system for the pad.
Definition: TPad.cxx:5173
virtual void SetBorderSize(Short_t bordersize)
Definition: TPad.h:321
void SetHatchesSpacing(Double_t h)
Definition: TStyle.h:288
void SetHatchesLineWidth(Int_t l)
Definition: TStyle.h:287
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
TCanvas * fillpatterns(int w=500, int h=700)
Definition: fillpatterns.C:23
Double_t y[n]
Definition: legend1.C:17
auto * l
Definition: textangle.C:4