Re: TPolyLine question

Rene Brun (Rene.Brun@cern.ch)
Tue, 11 Nov 1997 19:00:34 +0100


Laurent Aphecetche wrote:

> Hi,
>
> I have a canvas with a TPolyLine inside.
> I would like to fill it.
>
> root [0] Float_t x[4] = { 0.1,0.5,0.25,0.1}
> root [1] Float_t y[4] = { 0.1,0.1,0.25,0.1}
> root [2] TCanvas* c2 = new TCanvas("c2","coucou",400,400);
> root [3] TPolyLine* l = new TPolyLine(4,x,y) ;
> root [4] l->SetFillStyle(1001) ;
> root [5] l->SetFillColor(2) ;
> root [6] l->Draw() ;
>
> The line is not filled at all !
> What am I doing wrong ?
>
> (the final objective is to modify the line once it has been drawed. Is
> this possible ?)

The class TPolyLine does not support fill areas. Use TGraph instead.
See macro below.

{
gROOT->Reset();
Float_t x[4] = { 0.1,0.5,0.25,0.1};
Float_t y[4] = { 0.1,0.1,0.25,0.1};
TCanvas* c2 = new TCanvas("c2","coucou",400,400);
// TPolyLine* l = new TPolyLine(4,x,y) ;
TGraph* l = new TGraph(4,x,y) ;
l->SetFillStyle(1001) ;
l->SetFillColor(2) ;
l->Draw("f") ;
}

Rene Brun