0

This is Similar to the Previous Snippet, but it puts indivdual pixels of different colors randomly on the screen. Also makes a nice screensaver!

Progam RandColorPixel;

Uses Crt, Graph;

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

Begin
   GraphDriver := Detect;  {Automatically Detects Graphics Driver}
   InitGraph(GraphDriver, GraphMode, ' ');  {The ' ' is where the BGI Folder is on your HardDrive, for me it is 'C:\TP\BGI'}
   X := GetMaxX;
   Y := GetMaxY;
   Randomize;

   While Not Keypressed Do
   Begin
      Delay(20);  {Delays drawing to once every 20 milliseconds}
      SetColor(1 + Random(GetMaxColor));
      PutPixel(Random(X), Random(Y), 10); {For Some Reason, Pascal wants a third value, I'm not sure why...}
   End;
   
   Repeat Until Keypressed
   CloseGraph;
End.
4
Contributors
3
Replies
4
Views
12 Years
Discussion Span
Last Post by yvesli
0

I thought I had De Ja Vu for a second with the same snippet posted twice ... but then I read and saw it's slightly different.

I've no experience with Pascal. Where could I pick myself up a Pascal compiler to test this out?

0

really basic.

Pascal's third value is the colour for the pixel...

btw, to change an exe to windows screensaver format, just change the .exe to .scr . Then put it into your [main hard drive, usually C]\WINDOWS directory to make it available in Properties (Personalization->Screensaver on Vista).

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.