this slowpoke moves

Draw Animate Binary Clock

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Math, Menus;

type
  TForm1 = class(TForm)
    a0: TShape;
    a1: TShape;
    b0: TShape;
    b1: TShape;
    b2: TShape;
    b3: TShape;
    c0: TShape;
    c1: TShape;
    c2: TShape;
    d0: TShape;
    d1: TShape;
    d2: TShape;
    d3: TShape;
    e0: TShape;
    e1: TShape;
    e2: TShape;
    f0: TShape;
    f1: TShape;
    f2: TShape;
    f3: TShape;
    a2: TShape;
    c3: TShape;
    e3: TShape;
    Timer1: TTimer;
    a3: TShape;
    PopupMenu1: TPopupMenu;
    Close: TMenuItem;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure CloseClick(Sender: TObject);
    
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  zeit : string;
implementation

procedure zahl_darstellen(zahl : integer; reihe : char);
var i : integer;
begin
  for i := 3 downto 0 do
  begin
    if zahl >= IntPower(2,i) then
      begin
      zahl := zahl - Trunc(IntPower(2,i));
      TShape(Form1.FindComponent(reihe + inttostr(i))).Brush.Color := clRed;
      end;
  end;
end;
{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  a0.Brush.Color := clwhite;
  a1.Brush.Color := clwhite;
  b0.Brush.Color := clwhite;
  b1.Brush.Color := clwhite;
  b2.Brush.Color := clwhite;
  b3.Brush.Color := clwhite;
  c0.Brush.Color := clwhite;
  c1.Brush.Color := clwhite;
  c2.Brush.Color := clwhite;
  d0.Brush.Color := clwhite;
  d1.Brush.Color := clwhite;
  d2.Brush.Color := clwhite;
  d3.Brush.Color := clwhite;
  e0.Brush.Color := clwhite;
  e1.Brush.Color := clwhite;
  e2.Brush.Color := clwhite;
  f0.Brush.Color := clwhite;
  f1.Brush.Color := clwhite;
  f2.Brush.Color := clwhite;
  f3.Brush.Color := clwhite;
  zeit := timetostr(time);
  zahl_darstellen(strtoint(zeit[1]), 'a');
  zahl_darstellen(strtoint(zeit[2]), 'b');
  zahl_darstellen(strtoint(zeit[4]), 'c');
  zahl_darstellen(strtoint(zeit[5]), 'd');
  zahl_darstellen(strtoint(zeit[7]), 'e');
  zahl_darstellen(strtoint(zeit[8]), 'f');
  form1.Hint := timetostr(time);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  zeit := timetostr(time);
  zahl_darstellen(strtoint(zeit[1]), 'a');
  zahl_darstellen(strtoint(zeit[2]), 'b');
  zahl_darstellen(strtoint(zeit[4]), 'c');
  zahl_darstellen(strtoint(zeit[5]), 'd');
  zahl_darstellen(strtoint(zeit[7]), 'e');
  zahl_darstellen(strtoint(zeit[8]), 'f');
  form1.left := Monitor.Width - form1.width;
  form1.top  := Monitor.Height- form1.height;
end;

procedure TForm1.CloseClick(Sender: TObject);
begin
  Close;
end;

end.

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate