Last Update: Tuesday, 21-Sep-1999 01:22:23 MEST
Last Visitor: 64-191-81-117.hostnoc.net using 3GSE bot (Internet Research Institute UK, http://iri-uk.com) on 19.8.2008 23:47 (1469)
Important: This page is no longer maintained since I moved to www.clackas.de. Please use the new pages.




This is an example of PAS2HTML written in Delphi by me.

{©  1997  Christian  Lackas,  delta@earthling.net
 http://www.yi.com/home/LackasChris
 TQuix  draws  a  group  of  lines  bouncing  around  the  screen.
 special  Properties:
 LineColor  :  TColor   Color  of  the  drawn  lines
 Lines      :  Byte     Number  of  lines  <100
 Step       :  Byte     Difference  between  two  lines
 Thickness  :  Byte     Thickness  of  each  line  in  pixel
 Wait       :  Byte     Time  [in  ms]  betwenn  to  draw-cycles
}

UNIT  quix;

INTERFACE

USES
  Windows,  Messages,  SysUtils,  Classes,  Graphics,  Controls,  Forms,  Dialogs,
  ExtCtrls;

TYPE
  TQuix  =  CLASS(TPaintBox)
  PRIVATE
    {  Private-Deklarationen  }
    FLineColor:  TColor;
    FLines:  Byte;
    FWait:  Byte;
    FStep:  Byte;
    FThickness:  Integer;
    PROCEDURE  SetLineColor(clNew:TColor);
    PROCEDURE  SetLines(bNew:Byte);
    PROCEDURE  SetWait(bNew:Byte);
    PROCEDURE  SetStep(bNew:Byte);
    PROCEDURE  SetThickness(bNew:Integer);
  PROTECTED
    {  Protected-Deklarationen  }
  PUBLIC
    {  Public-Deklarationen  }
    CONSTRUCTOR  Create(Owner:TComponent);  override;
    DESTRUCTOR  Destroy;  override;
    PROCEDURE  Start;
    PROCEDURE  Stop;
    PROCEDURE  ReStart;
    PROCEDURE  Draw;
  PUBLISHED
    {  Published-Deklarationen  }
    PROPERTY  LineColor:  TColor  read  FLineColor  write  SetLineColor;
    PROPERTY  Lines:  Byte  read  FLines  write  SetLines  ;
    PROPERTY  Wait:  Byte  read  FWait  write  SetWait  ;
    PROPERTY  Step:  Byte  read  FStep  Write  SetStep;
    PROPERTY  Thickness:  Integer  read  FThickness  write  SetThickness;
  END;

PROCEDURE  Register;

IMPLEMENTATION
CONST  maxLines=100;
      maxWait  =  30;
VAR  x1,x2,y1,y2:  ARRAY[1..maxLines]  OF  Integer;
    vx1,vx2,vy1,vy2:  Integer;
    Ende:  Boolean;

CONSTRUCTOR  TQuix.Create(Owner:TComponent);
BEGIN
  INHERITED  Create(Owner);
  Width:=100;
  Height:=50;
  FLines:=25;
  FLineColor:=clBlack;
  FWait:=5;
  FStep:=10;
  FThickness:=1;
  ParentColor:=True;
  Ende:=True;
END;

DESTRUCTOR  TQuix.Destroy;
BEGIN
  INHERITED  Destroy;
END;

PROCEDURE  TQuix.SetLineColor(clNew:TColor);
BEGIN
  FLineColor:=clNew;
  Refresh;
END;

PROCEDURE  TQuix.SetLines(bNew:  Byte);
BEGIN
  IF  bNew<MaxLines  THEN
  BEGIN
    FLines:=bNew;
    Refresh;
  END;
END;

PROCEDURE  TQuix.SetWait(bNew:  Byte);
BEGIN
  IF  bNew<MaxWait  THEN
  BEGIN
    FWait:=bNew;
    Refresh;
  END;
END;

PROCEDURE  TQuix.SetStep(bNew:Byte);
BEGIN
  IF  bNew>2  THEN
  BEGIN
    FStep:=bNew;
    Refresh;
  END;
END;

PROCEDURE  TQuix.SetThickness(bNew:Integer);
BEGIN
  IF  (bNew>0)  AND  (bNew<(FStep-1))  THEN
  BEGIN
    FThickness:=bNew;
    Refresh;
  END;
END;

PROCEDURE  TQuix.Start;
VAR  i:Byte;
    ClearRect:  TRect;
BEGIN
  Randomize;
  Ende:=False;
  ParentColor:=True;
  ClearRect  :=  Rect(0,  0,  Width,  Height);
  Canvas.Brush.Style  :=  bsSolid;
  Canvas.Brush.Color  :=  Color;
  Canvas.FillRect(ClearRect);
  Canvas.Pen.Width:=FThickness;
  FOR  i:=2  TO  FLines  DO
  BEGIN
    x1[i]:=0;x2[i]:=0;y1[i]:=0;y2[i]:=0;
  END;
  REPEAT
    vx1:=Random(2*FStep+(FStep  DIV  2))-FStep;
    vy1:=Random(2*FStep+(FStep  DIV  2))-FStep;
    vx2:=Random(2*FStep+(FStep  DIV  2))-FStep;
    vy2:=Random(2*FStep+(FStep  DIV  2))-FStep;
  UNTIL  (((vx1*vy1*vx2*vy2)<>0)  AND  (vx1<>vx2)  AND  (vy1<>vy2));
  x1[1]:=Random(Width-10)+5;
  x2[1]:=Random(Width-10)+5;
  y1[1]:=Random(Height-10)+5;
  y2[1]:=Random(Height-10)+5;
  Draw;
END;

PROCEDURE  TQuix.Draw;
VAR  i:  Byte;
BEGIN
  REPEAT
    {Löschen}
    Canvas.Pen.Color:=Color;
    Canvas.MoveTo(x1[FLines],y1[FLines]);
    Canvas.LineTo(x2[FLines],y2[FLines]);
    FOR  i:=FLines  DOWNTO  2  DO
    BEGIN
      x1[i]:=x1[i-1];
      x2[i]:=x2[i-1];
      y1[i]:=y1[i-1];
      y2[i]:=y2[i-1];
    END;
    inc(x1[1],vx1);
    inc(x2[1],vx2);
    inc(y1[1],vy1);
    inc(y2[1],vy2);
    IF  ((x1[1]>Width)  OR  (x1[1]<0))  THEN  BEGIN  vx1:=-vx1;  inc(x1[1],vx1);  END;
    IF  ((x2[1]>Width)  OR  (x2[1]<0))  THEN  BEGIN  vx2:=-vx2;  inc(x2[1],vx2);  END;
    IF  ((y1[1]>Height)  OR  (y1[1]<0))  THEN  BEGIN  vy1:=-vy1;  inc(y1[1],vy1);  END;
    IF  ((y2[1]>Height)  OR  (y2[1]<0))  THEN  BEGIN  vy2:=-vy2;  inc(y2[1],vy2);  END;
    {Malen}
    Canvas.Pen.Color:=FLineColor;
    Canvas.MoveTo(x1[1],y1[1]);
    Canvas.LineTo(x2[1],y2[1]);
    Application.ProcessMessages;
    Sleep(FWait);
  UNTIL  Ende;
END;

PROCEDURE  TQuix.Stop;
BEGIN
  Ende:=True;
END;

PROCEDURE  TQuix.Restart;
BEGIN
  Ende:=False;
  Draw;
END;

PROCEDURE  Register;
BEGIN
  RegisterComponents('Delta',  [TQuix]);
END;

END.

Copyright © 1997 Christian Lackas, delta@earthling.net