this slowpoke moves

Draw Graphical Counter

const
  Nombre_seconde = 10;
  Image_par_seconde = 30;
var
  Fond, Prep : TBitmap; 
  Affichage_en_Cours : boolean = false; 
  Temp_Rebo : integer;
  
//

procedure Graphic(Temp : integer);
var
  Rect1 : TRect; 
  Tail, Rayo, Gauc, Ecar : integer;
  Angl : single;
  Anci_Chif, Nouv_Chif : string; 
begin
  Ecar := Image_par_seconde;
  Prep.Canvas.Brush.Color := ClBlack;
  Prep.Canvas.Pen.Color := ClBlack;
  Prep.Canvas.Rectangle (0, 0, Prep.Width, Prep.Height);
  Fond.Canvas.Brush.Color := ClBlack;
  Fond.Canvas.Pen.Color := ClBlack;
  Fond.Canvas.Rectangle (0, 0, Fond.Width, Fond.Height);
  Rayo := Prep.Height div 2;
  Gauc := Prep.Width div 2 - Rayo;
  Tail := (Prep.Height div 3)*2;
  Prep.Canvas.Font.Color := clWhite;
  Prep.Canvas.Font.Name := 'Arial';
  Prep.Canvas.Font.Height := Tail;
  Prep.Canvas.Font.Style := [fsBold];
  Fond.Canvas.Font.Color := clWhite;
  Fond.Canvas.Font.Name := 'Arial';
  Fond.Canvas.Font.Height := Tail;
  Fond.Canvas.Font.Style := [fsBold];
  Anci_Chif := inttostr (((Temp) div Ecar) + 1);
  Prep.Canvas.TextOut ( (Prep.Width - Prep.Canvas.TextWidth (Anci_Chif) ) div 2,
      (Prep.Height - Prep.Canvas.TextHeight (Anci_Chif) ) div 2,
       Anci_Chif);
  Angl := - ((Temp) mod Ecar * 2 * PI)/Ecar + Pi;
  Prep.Canvas.Pie (Gauc, 0, Gauc + 2 * Rayo, 2 * Rayo,
          Gauc + Rayo, 0,
          (Gauc + Rayo) + round (Rayo * sin (Angl)), Rayo + round (Rayo * cos(Angl)));
  Nouv_Chif := inttostr ((Temp) div Ecar);
  Fond.Canvas.TextOut ( (Fond.Width - Fond.Canvas.TextWidth (Nouv_Chif) ) div 2,
      (Fond.Height - Fond.Canvas.TextHeight (Nouv_Chif) ) div 2,
       Nouv_Chif);
  if abs (Angl - Pi) > 0.001 then
  Fond.Canvas.Pie (Gauc, 0, Gauc + 2 * Rayo, 2 * Rayo,
          (Gauc + Rayo) + round (Rayo * sin (Angl)), Rayo + round (Rayo * cos(Angl)),
          Gauc + Rayo, 0);
  Rect1 := Rect (0, 0, Fond.Width, Fond.Height);
  Prep.Canvas.CopyMode := cmSrcPaint;
  Prep.Canvas.CopyRect (Rect1, Fond.Canvas, Rect1);
  Form1.PaintBox1.Canvas.Pen.Mode := pmCopy;
  Form1.PaintBox1.Canvas.CopyRect (Rect1, Prep.Canvas, Rect1);
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
begin
if not Affichage_En_Cours then
  begin
  Affichage_En_Cours := true;
  Fond := TBitmap.Create;
  Prep := TBitmap.Create;
  Fond.Width := PaintBox1.Width;
  Fond.Height := PaintBox1.Height;
  Prep.Width := PaintBox1.Width;
  Prep.Height := PaintBox1.Height;
  Timer1.Enabled := true;
  Timer1.Interval := 1000 div Image_par_seconde;
  Temp_Rebo := Nombre_seconde * Image_par_seconde;
  end;
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate