This is Similar to the Previous Snippet, but it puts indivdual pixels of different colors randomly on the screen. Also makes a nice screensaver!
Random Colored Pixels
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.
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member
another guest -17 Junior Poster in Training
yvesli 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.