The Realm of Real

..rjproz's blog..

C++ Graphics Fun

See and try out to see the one of the most sensational c++ graphics for fun. Following code needs BGI graphics driver.

RandomPixel.cpp 
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
int gd=DETECT,gm;
randomize();
/* Give path of the BGI folder /*
initgraph(&gd,&gm,"f:\bc5\bgi");

while(!kbhit())
{


putpixel(random(getmaxx()+1),random(getmaxy()+1),RGB(random(256), random(256), random(256)));



}
getch();
closegraph();
}

Output of RandomPixel.cpp
  
RandomCircle.cpp 
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
#include <windows.h>
void main()
{
int gd=DETECT,gm;
randomize();
initgraph(&gd,&gm,"f:\bc5\bgi");

while(!kbhit())
{

setcolor(RGB(random(256), random(256), random(256)));
circle(random(getmaxx()+1),random(getmaxy()+1),random(getmaxy()+1));

}
getch();
closegraph();
}

Output of RandomCircle.cpp

Leave a Reply

Your email address will not be published. Required fields are marked *