currently a TApplication environment is needed when doing graphics.
As you've noticed the colors are initialized in the application ctor
and without it no graphics will work properly (even in batch with
only PostScript output). I've added in TCanvas a protection, in case
no TApplication exists it will create a default one before drawing
anything. So in the next release you can remove the TApplication
from your little example below.
Cheers, Fons.
Yasuhiro SHIRASAKI wrote:
>
> Hi ROOTers,
>
> Why TColor initialization is placed in TApplication?
> Following batch mode application generates plain paper,
> when TApplication is commented out.
>
> As it is not GUI application, I think there is no need
> to make TApplication instance.
>
> ------------------------------------------------------------
> #include "TROOT.h"
> #include "TApplication.h"
> #include "TCanvas.h"
> #include "TF1.h"
> #include "TMath.h"
>
> int main(int argc, char** argv)
> {
> TROOT Root("Root", "RootApp");
> // TApplication theApp("App", &argc, argv);
>
> TCanvas c("test", "test"); c.Draw();
> TF1 f("sin", "sin(x)", -TMath::Pi(), TMath::Pi()); f.Draw();
> c.Print();
>
> return 0;
> }
> ------------------------------------------------------------
>
> regards,
>
> --
> Yasuhiro SHIRASAKI : Experimental Particle Physics, JLC Team
> Graduate school of Science, TOHOKU University 980-8578 Japan.
> Phone: +81-22-217-6727 Fax: +81-22-217-6728
-- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland Phone: +41 22 7679248 E-Mail: Fons.Rademakers@cern.ch Fax: +41 22 7677910