0

This simple program will draw several randomly sized and colored lines on the screen. Makes a good screensaver!

Program RandColorLines;

Uses Crt, Graph;

Var GraphDriver, GraphMode: Integer;
      X, Y: Integer;

Begin
   GraphDriver := Detect; {This automatically detects the GraphicsDriver}
   InitGraph(GraphDriver, GraphMode, ' ');  
   {The ' ' is where the BGI file is stored on your Harddrive}
   {For me it is 'C:\TP\BGI'}
   X := GetMaxX;
   Y := GetMaxY;
   Randomize;  {This Enables the Random feature}

  While Not Keypressed Do
  Begin
      Delay(20);  {Delays drawing of a line to once every 20 milliseconds}
      SetColor(1 + Random(GetMaxColor));
      Line(Random(X), Random(Y), Random(X), Random(Y));
   End;

   Repeat Until Keypressed;
   Closegraph
End.


2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by Dani
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.