<commit_before>// @(#)root/test:$Name:  $:$Id: Hello.cxx,v 1.2 2000/07/11 18:05:26 rdm Exp $
// Author: <NAME> & <NAME>   04/10/98

///////////////////////////////////////////////////////////////////
//  Animated Text with cool wave effect.
//
//  ROOT implementation of the hello world example borrowed
//  from the Qt hello world example.
//
//  To run this example do the following:
//  $ root
//  root [0] gSystem.Load("Hello")
//  root [1] Hello h
//  <enjoy>
//  root [2] .q
//
//  Other ROOT fun examples: Tetris, Aclock ...
//
//  Begin_Html
// <img src="http://emcal06.rhic.bnl.gov/~onuchin/root/gif/hello_clock.gif">
//  End_Html
//
///////////////////////////////////////////////////////////////////

#include <TROOT.h>
#include <TSystem.h>
#include "Hello.h"


ClassImp(Hello)


TChar::TChar(char ch, Coord_t x, Coord_t y) : TText(x, y, "")
{
   // Create single character text.

   char *tmp;
   tmp = (char*)GetTitle();
   tmp[0] = ch;
   SetTitle(tmp);
}

Float_t TChar::GetWidth()
{
   // Return character width

   UInt_t w,h;

   if (!TVirtualPad::Pad()) return 0;

   Float_t wh = (Float_t)gPad->XtoPixel(gPad->GetX2());
   gVirtualX->GetTextExtent(w, h, (char*)GetTitle());
   return  w/wh;
}


Hello::Hello(const char *text) : TTimer(40, kTRUE)
{
   // Hello constructor

   TChar *ch;
   fI = 0;
   fList = new TList();

   if (!TVirtualPad::Pad())
      fPad = new TCanvas("Hello:canvas","ROOT says Hello!",200,200,400,200);
   else
      fPad = (TPad*)gPad;

   while(text[fI]) {               // create  list of characters
      ch = new TChar(text[fI]);
      ch->SetTextFont(77);         // times-bold-r-normal
      ch->SetTextSize(0.3);
      ch->Modify();
      fI++;
      fList->Add(ch);
   }

   SetBit(kCanDelete);
   Draw();                         // append this to current pad
   Paint();                        // calculate new coordinates of chars and paint it
   gSystem->AddTimer(this);        // start timer= start animation
}

Hello::~Hello()
{
   // Clean up hello.

   fList->Delete();
   delete fList;
}

void Hello::ExecuteEvent(Int_t event, Int_t, Int_t)
{
   // Actions when mouse clicked.

   if (event == kButton1Up) {
      TTimer::Remove();
   }
}

Float_t Hello::GetWidth()
{
   // Return text width

   TChar *ch;
   TIter nextin(fList);
   Float_t width = 0;

   while ((ch = (TChar*)nextin()))
      width = width + ch->GetWidth();

   return width;
}

void Hello::Paint(Option_t *)
{
   // Paint text

   static int sin_tbl[16] = {
        0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
   };

   TChar *ch;
   TIter nextin(fList);
   Float_t width = GetWidth();

   Coord_t xnext = (1-width)/2.;    // draw text in the center of the pad
   Coord_t y;
   Coord_t y0 = 0.5;

   fI = (fI+1) & 15;
   int i = 0;

   while ((ch = (TChar*)nextin())) {
      int i16 = (fI+i) & 15;
      y = y0 - (Coord_t)sin_tbl[i16]/1500.;   // sin-wave coordinates
      ch->SetY(y);
      ch->SetX(xnext);
      ch->SetTextColor(i16+200);              // let's use x3d colors
      i++;
      xnext = xnext + ch->GetWidth();         // x position of next character
      ch->Paint("");                          // paint character
   }
}

Bool_t Hello::Notify()
{
   // Actions after timer time-out

   fPad->Modified();
   fPad->Update();
   TTimer::Reset();
   return kFALSE;
}
<commit_msg>Change the text font from 77 to 71. This change is necessary since the introduction in TAttText of precisions 3 and above where the font size is given in pixels instead of per cent of the pad.<commit_after>// @(#)root/test:$Name:  $:$Id: Hello.cxx,v 1.3 2000/12/21 09:20:29 brun Exp $
// Author: <NAME> & <NAME>   04/10/98

///////////////////////////////////////////////////////////////////
//  Animated Text with cool wave effect.
//
//  ROOT implementation of the hello world example borrowed
//  from the Qt hello world example.
//
//  To run this example do the following:
//  $ root
//  root [0] gSystem.Load("Hello")
//  root [1] Hello h
//  <enjoy>
//  root [2] .q
//
//  Other ROOT fun examples: Tetris, Aclock ...
//
//  Begin_Html
// <img src="http://emcal06.rhic.bnl.gov/~onuchin/root/gif/hello_clock.gif">
//  End_Html
//
///////////////////////////////////////////////////////////////////

#include <TROOT.h>
#include <TSystem.h>
#include "Hello.h"


ClassImp(Hello)


TChar::TChar(char ch, Coord_t x, Coord_t y) : TText(x, y, "")
{
   // Create single character text.

   char *tmp;
   tmp = (char*)GetTitle();
   tmp[0] = ch;
   SetTitle(tmp);
}

Float_t TChar::GetWidth()
{
   // Return character width

   UInt_t w,h;

   if (!TVirtualPad::Pad()) return 0;

   Float_t wh = (Float_t)gPad->XtoPixel(gPad->GetX2());
   gVirtualX->GetTextExtent(w, h, (char*)GetTitle());
   return  w/wh;
}


Hello::Hello(const char *text) : TTimer(40, kTRUE)
{
   // Hello constructor

   TChar *ch;
   fI = 0;
   fList = new TList();

   if (!TVirtualPad::Pad())
      fPad = new TCanvas("Hello:canvas","ROOT says Hello!",200,200,400,200);
   else
      fPad = (TPad*)gPad;

   while(text[fI]) {               // create  list of characters
      ch = new TChar(text[fI]);
      ch->SetTextFont(71);         // times-bold-r-normal
      ch->SetTextSize(0.3);
      ch->Modify();
      fI++;
      fList->Add(ch);
   }

   SetBit(kCanDelete);
   Draw();                         // append this to current pad
   Paint();                        // calculate new coordinates of chars and paint it
   gSystem->AddTimer(this);        // start timer= start animation
}

Hello::~Hello()
{
   // Clean up hello.

   fList->Delete();
   delete fList;
}

void Hello::ExecuteEvent(Int_t event, Int_t, Int_t)
{
   // Actions when mouse clicked.

   if (event == kButton1Up) {
      TTimer::Remove();
   }
}

Float_t Hello::GetWidth()
{
   // Return text width

   TChar *ch;
   TIter nextin(fList);
   Float_t width = 0;

   while ((ch = (TChar*)nextin()))
      width = width + ch->GetWidth();

   return width;
}

void Hello::Paint(Option_t *)
{
   // Paint text

   static int sin_tbl[16] = {
        0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
   };

   TChar *ch;
   TIter nextin(fList);
   Float_t width = GetWidth();

   Coord_t xnext = (1-width)/2.;    // draw text in the center of the pad
   Coord_t y;
   Coord_t y0 = 0.5;

   fI = (fI+1) & 15;
   int i = 0;

   while ((ch = (TChar*)nextin())) {
      int i16 = (fI+i) & 15;
      y = y0 - (Coord_t)sin_tbl[i16]/1500.;   // sin-wave coordinates
      ch->SetY(y);
      ch->SetX(xnext);
      ch->SetTextColor(i16+200);              // let's use x3d colors
      i++;
      xnext = xnext + ch->GetWidth();         // x position of next character
      ch->Paint("");                          // paint character
   }
}

Bool_t Hello::Notify()
{
   // Actions after timer time-out

   fPad->Modified();
   fPad->Update();
   TTimer::Reset();
   return kFALSE;
}

{'fraction_non_alphanumeric': 0.19831591173054589, 'fraction_numerical': 0.032955865272938444, 'mean_word_length': 2.001742919389978, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5124890', 'n_tokens_mistral': 2628, 'n_tokens_neox': 2412, 'n_words': 636}