19 void triangles(Int_t ntriangles=50) {
 
   20    TCanvas *c1 = 
new TCanvas(
"c1",
"triangles",10,10,700,700);
 
   22    Double_t dx = 0.2; Double_t dy = 0.2;
 
   23    Int_t ncolors = gStyle->GetNumberOfColors();
 
   27    for (Int_t i=0;i<ntriangles;i++) {
 
   28       x[0] = r.Uniform(.05,.95); y[0] = r.Uniform(.05,.95);
 
   29       x[1] = x[0] + dx*r.Rndm(); y[1] = y[0] + dy*r.Rndm();
 
   30       x[2] = x[1] - dx*r.Rndm(); y[2] = y[1] - dy*r.Rndm();
 
   31       x[3] = x[0];               y[3] = y[0];
 
   32       TPolyLine *pl = 
new TPolyLine(4,x,y);
 
   34       ci = ncolors*r.Rndm();
 
   35       c  = gROOT->GetColor(TColor::GetColorPalette(ci));
 
   36       c->SetAlpha(r.Rndm());
 
   40    c1->AddExec(
"ex",
"TriangleClicked()");
 
   43 void TriangleClicked() {
 
   47    int event = gPad->GetEvent();
 
   48    if (event != 11) 
return; 
 
   49    TObject *select = gPad->GetSelected();
 
   51    if (select->InheritsFrom(TPolyLine::Class())) {
 
   52       TPolyLine *pl = (TPolyLine*)select;
 
   53       printf(
"You have clicked triangle %d, color=%d\n",
 
   54               pl->GetUniqueID(),pl->GetFillColor());