https://github.com/root-project/root
Raw File
Tip revision: a48bb7fe1e147de1fad7e8775a664518df516f81 authored by Unknown Author on 29 May 2006, 10:03:03 UTC
This commit was manufactured by cvs2svn to create tag 'v5-10-00e'.
Tip revision: a48bb7f
greyscale.C
{
   // Create grey scale of nxn boxes.

   if (gVirtualX) {
      Int_t n;
      gVirtualX->GetPlanes(n);
      if (n < 15) {
         printf("Not enough color planes to run this script\n");
         return;
      }
   }

   TCanvas *c = new TCanvas("grey", "Grey Scale", 500, 500);
   c->SetBorderMode(0);

   Int_t   n = 200;   // tunable parameter
   Float_t n1 = 1./n;
   for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
         TBox *b = new TBox(n1*j, n1*(n-1-i), n1*(j+1), n1*(n-i));
         Float_t grey = Float_t(i*n+j)/(n*n);
         b->SetFillColor(TColor::GetColor(grey, grey, grey));
         b->Draw();
      }
   }
   TPad *p = new TPad("p","p",0.3, 0.3, 0.7,0.7);
   const char *guibackground = gEnv->GetValue("Gui.BackgroundColor", "");
   p->SetFillColor(TColor::GetColor(guibackground));
   p->Draw();
   p->cd();
   TText *t = new TText(0.5, 0.5, "GUI Background Color");
   t->SetTextAlign(22);
   t->SetTextSize(.09);
   t->Draw();

   c->SetEditable(kFALSE);
}
back to top