greyscale.C

Go to the documentation of this file.
00001 {
00002    // Create grey scale of nxn boxes.
00003    //Author: Olivier Couet
00004    
00005    if (gVirtualX) {
00006       Int_t n;
00007       gVirtualX->GetPlanes(n);
00008       if (n < 15) {
00009          printf("Not enough color planes to run this script\n");
00010          return;
00011       }
00012    }
00013 
00014    TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
00015    c->SetBorderMode(0);
00016 
00017    Int_t   n = 200;   // tunable parameter
00018    Float_t n1 = 1./n;
00019    for (int i = 0; i < n; i++) {
00020       for (int j = 0; j < n; j++) {
00021          TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
00022          Float_t grey = Float_t(i*n+j)/(n*n);
00023          b->SetFillColor(TColor::GetColor(grey, grey, grey));
00024          b->Draw();
00025       }
00026    }
00027    TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
00028    const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
00029    p->SetFillColor(TColor::GetColor(guibackground));
00030    p->Draw();
00031    p->cd();
00032    TText *t = new TText(0.5, 0.5, "GUI Background Color");
00033    t->SetTextAlign(22);
00034    t->SetTextSize(.09);
00035    t->Draw();
00036 
00037    c->SetEditable(kFALSE);
00038 }

Generated on Tue Jul 5 15:44:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1