Computer Training and Examination Cetner
Under the Patronage of
      Online Payment     Online Payment
Your Ad Here

Chapter 13 Graphics In C

Back to -> C-Langauge Tutorial Index

About Graphics

Firstly you should know the function initgraph which is used to initialize the graphics mode . 
To initialize graphics mode we use initgraph function in our program. initgraph function is present in "graphics.h" header file, 
so your every graphics program should include "graphics.h" header file. 
We will discuss initgraph withe help of following sample program:-
Graphics Program to Move Car

#include <graphics.h>
#include <dos.h>
#include <conio.h> 
 
main()
{
   int i, j = 0, gd = DETECT, gm;
 
   initgraph(&gd,&gm,"C:\\TC\\BGI");
 
   settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
   outtextxy(25,240,"Press any key to view the moving car");
 
   getch();
   setviewport(0,0,639,440,1);
 
   for( i = 0 ; i <= 420 ; i = i + 10, j++ )
   {
      rectangle(50+i,275,150+i,400);
      rectangle(150+i,350,200+i,400);
      circle(75+i,410,10);
      circle(175+i,410,10);
      setcolor(j);
      delay(100);
 
      if( i == 420 )
         break;
 
      clearviewport();
   }
 
   getch();
   closegraph();
   return 0;
}

Back to -> C Language Tutorial Index

Your Ad Here
© Copyright OBM-INDIA 2008-2013 Designed by OBM-INDIA Privacy Policy | Terms of Use