Example #1
0
void checkerrors()
   {
   int   code;

   code = graphresult();
   if (code!=grOk)
      {
      outtextxy(10, 460, grapherrormsg(code));
      getch();
      cleardevice();
      closegraph();
      exit (fprintf(stderr, "error = %s\n", grapherrormsg(code))!=0);
      }
   }
Example #2
0
void InitGraphics() {
   int gdriver = VGA, gmode=VGAHI, errorcode;
   initgraph(&gdriver, &gmode, "");
   errorcode = graphresult();
   if (errorcode != grOk)
      Error("Graphics error: %s\n", grapherrormsg(errorcode));
}
Example #3
0
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int x,y,sz,b,c,szin;
    randomize(); //random urit
   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "D:\\TC\\bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   /* draw the circle */
   setcolor(LIGHTGREEN);
   circle(319,239,120);
   setfillstyle(1,YELLOW); //1=teli kit”lt‚s, ‚s ezzel a sz¡nnel tolt ki
   floodfill(319,239,LIGHTGREEN); //eddig a sz¡nig t”lts”n ki

   setcolor(LIGHTBLUE);
   circle(269,179,30);
   setfillstyle(1,BLUE);
   floodfill(269,179,LIGHTBLUE);

   setcolor(BLUE);
   ellipse(369,179,0,360,50,30);
   setfillstyle(1,BLUE);
   floodfill(369,179,BLUE);

   setcolor(RED);
   setlinestyle(1,1,3);
   arc(319,239,235,315,80);  //x,y,kezdoszog,vegszog,sugar

   setcolor(11);
   settextstyle(GOTHIC_FONT,0,4);
   outtextxy(10,50,"Nyomj egy gombot!");
   getch();

   sz=30;
   b=1;
   while(!kbhit())
   {
    if(b==1)
     setcolor(YELLOW);
     ellipse(369,179,0,360,50,sz);
     if (sz>0) sz=sz-1;
     else
     {
      b=0;
      szin=random(15)+1;
     }
    }
    else
    {
Example #4
0
int main(void)
{
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy, hj, vj;
   char msg[80];
   initgraph(&gdriver, &gmode, "\\bc\\bgi");
   errorcode = graphresult();
   if (errorcode != grOk)
   {
      printf("error ao inicar modo grafico : %s\n", grapherrormsg(errorcode));
      printf("Nao foi possivel abrir modo grafico ");
      getch();
   }
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   for (hj=LEFT_TEXT; hj<=RIGHT_TEXT; hj++)
      for (vj=LEFT_TEXT; vj<=RIGHT_TEXT; vj++)
      {
	 cleardevice();
	 settextjustify(hj, vj);
	 sprintf(msg, "%s  %s", hjust[hj], vjust[vj]);
	 xat(midx, midy);
	 outtextxy(midx, midy, msg);
	 getch();
      } closegraph();
   return 0;
}
Example #5
0
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "C:\\Turboc3\\BGI");

   /* read result of initialization */
   errorcode = graphresult();
   /* an error occurred */
   if (errorcode != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }

   setcolor(getmaxcolor());
   //xmax = getmaxx();
  // ymax = getmaxy();
   line(50,50,100,50);
   line(100,50,100,100);
   line(100,100,50,100);
   line(50,50,50,100);
   //printf("%d",getpixel(70,70));
   boundaryFill(70,70,getmaxcolor());
   getch();
   closegraph();
   return 0;
}
main()
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int xmax, ymax;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   /* an error occurred */
   if (errorcode != grOk)
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
   }

   setcolor(getmaxcolor());
   xmax = 10;
   ymax = 10;

   /* draw a diagonal line */
   line(0, 0, xmax, ymax);

   /* clean up */
   getch();
  // closegraph();
   return 0;
}
void main()
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }
   cout<<"enter the coordinate x y of endpoinr p1:";
   cin>>p[0][0]>>p[0][1];
   cout<<"enter the coordinate x y of endpoint p4:";
   cin>>p[1][0]>>p[1][1];
   cout<<"enter the coordinate x y of tangent point r1:";
   cin>>p[2][0]>>p[2][1];
   cout<<"enter the coordinate x y of tangent point r2:";
   cin>>p[3][0]>>p[3][1];
   hermite();
   getch();
   closegraph();

}
void main()
{
  int ch;
  clrscr();
  while(1)
  {
   initgraph(&gdriver, &gmode, "");
   errorcode = graphresult();
   if (errorcode != grOk)
    {
      printf("%d",errorcode);
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1);
    }
   cleardevice();
   setbkcolor(6);
   setcolor(15);
   settextstyle(1,0,1);
   sprintf(msg,"SRI JAYACHAMARAJENDRA COLLEGE OF ENGINEERING");
   outtextxy(75,10,msg);
   sprintf(msg,"MYSORE-570006");
   outtextxy(230,40,msg);
   sprintf(msg,"STUDENT DATABASE");
   outtextxy(220,100,msg);
   sprintf(msg,"1. INSERT A RECORD");
   outtextxy(200,200,msg);
   sprintf(msg,"2. ACCESS A RECORD");
   outtextxy(200,240,msg);
   sprintf(msg,"3. DELETE A RECORD");
   outtextxy(200,280,msg);
   sprintf(msg,"4. DISPLAY THE DATABASE");
   outtextxy(200,320,msg);
   sprintf(msg,"5. EXIT");
   outtextxy(200,360,msg);
   sprintf(msg," Please enter your choice:");
   outtextxy(220,400,msg);
   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
   printf("\n\t\t\t\t\t");
   scanf("%d",&ch);
   clrscr();
   switch(ch)
      {
	      case 1:write();
		     break;
	      case 2:read();
		     break;
	      case 3:del();
		     break;
	      case 4:display();
		     break;
	      case 5:exit(0);
	      default:printf("Wrong Choice:Please enter a valid choice");
      }
      getch();
      closegraph();
    }
}
int main(void)
{

void    *gothic_fontp;    /* points to font bufferin memory */
int      handle;          /* file handle used for I/O */
unsigned fsize;           /* size of file (andbuffer) */

int errorcode;
int graphdriver;
int graphmode;

/* open font file */
handle = open("LCOM.CHR", O_RDONLY|O_BINARY);
if (handle == -1)
{
printf("unable to open font file 'LCOM.CHR'\n");
exit(1);
}
/* find out size of the file */
fsize = filelength(handle);
/* allocate buffer */
gothic_fontp = malloc(fsize);
if (gothic_fontp == NULL)
{
printf("unable to allocate memory for font file'LCOM.CHR'\n");
exit(1);
}
/* read font into memory */
if (read(handle, gothic_fontp, fsize) != fsize)
{
printf("unable to read font file 'LCOM.CHR'\n");
exit(1);
}
/* close font file */
close(handle);
/* register font */
if (registerfarbgifont(gothic_fontp) != 8)     //
{
printf("unable to register font file 'LCOM.CHR'\n");
exit(1);
}
/* detect and initialize graphix */
graphdriver = DETECT;
initgraph(&graphdriver, &graphmode, "..");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("graphics error:%s\n",grapherrormsg(errorcode));
exit(1);
}
settextstyle(8, HORIZ_DIR, 4);


   sscreen( );
   getch();
   closegraph();

   return 0;
}
Example #10
0
int main(void)
{
clrscr();
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   void *arrow;
   int x, y, maxx;
   unsigned int size;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "d:\\tc\\bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   maxx = getmaxx();
   x = 0;
   y = getmaxy() / 2;

   /* draw the image to be grabbed */
   draw_arrow(x, y);

   /* calculate the size of the image */
   size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);

   /* allocate memory to hold the image */
   arrow = malloc(size);

   /* grab the image */
   getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);

   /* repeat until a key is pressed */
   while (!kbhit())
   {
      /* erase old image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);

      x += ARROW_SIZE;
      if (x >= maxx)
          x = 0;

      /* plot new image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
   }

   /* clean up */
   free(arrow);
   closegraph();
   return 0;
}
Example #11
0
int main(void)
{
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy,tam=5,cor=15;
   char texto[35];
   int letra=0;
   time_t t;
   char *fname[] = { "DEFAULT font",
		  "TRIPLEX font",
		  "SMALL font",
		  "SANS SERIF font",
		  "GOTHIC font"
		};
   initgraph(&gdriver,&gmode,"\\bc\\bgi");
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }
   midx = getmaxx();
   midy = 240;

   printf("Digite o Texto: ");
   gets(texto);
   flushall();

   srand((unsigned) time(&t));
   cleardevice();
   while(!kbhit())
   {
     settextstyle(SANS_SERIF_FONT, HORIZ_DIR, tam);
     setcolor(cor);
     outtextxy(midx, midy, texto);
     delay(10);
     setcolor(0);
     outtextxy(midx, midy, texto);
     midx-=2;

     if(midx<=(textwidth(texto)*-1))
     {
       tam=rand()%10;
       cor=rand()%15;
       if(cor==0)
	 cor=1;
       midx=640;
       midy =rand()% 480;
       letra=rand()%5;
     }
   }

   /* clean up */
   closegraph();
   return 0;
}
Example #12
0
void main()
{
 int col,n,xx[10],yy[10],x,y,sy,sx,ch,gtx[5],gty[5],k=0;
mouse m;
polygon p;
int gdriver = DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "");

errorcode = graphresult();

if (errorcode != grOk)
{
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();
   exit(1);
}
m.initmouse();
m.showmouse();
 int click,i=0,x1,y1,x2,y2;
 do
 {
   delay(100);

   m.getmousepos(click,x,y);
   if(click==1)
	{
	  xx[k]=x;
	  yy[k]=y;
	  i++;
	  gtx[i]=x;
	  gty[i]=y;
	  k++;
	  if(i==2)
	  {
		x2=gtx[i];
		y2=gty[i];
		x1=gtx[1];
		y1=gty[1];
		p.bres(x1,y1,x2,y2);
		i=1;
		gtx[1]=x2;
		gty[1]=y2;
	  }
	}
 }while(!kbhit());
xx[k]=xx[0];
yy[k]=yy[0];
n=k;
p.scanfill(xx,yy,RED,n);

getch();
closegraph();
}
Example #13
0
void open_graphics(void) {
    int g_driver,g_mode,g_error;

    g_driver=DETECT;
    initgraph(&g_driver,&g_mode,"C:\\BORLANDC\\BGI");
    g_error=graphresult();
    if(g_error<0) {
        printf("INITGRAPH ERROR : %s.\n",grapherrormsg(g_error));
        exit(1);
    }
}
Example #14
0
/* ----------------- INIT AND DESTROY GRAPHICS MODE -----------------------*/
void initgraphix(){
int gd=DETECT;   /* request auto detection */
int gm;
int errcode;
  initgraph(&gd,&gm,"..\\bgi");
  errcode=graphresult();
  if (errcode!=grOk){
      printf("Graphics error : %s.\n",grapherrormsg(errcode));
      getch();
      exit(1);
  }
}
void init_graph()
{
 int gdriver = DETECT, gmode, errorcode;
 initgraph(&gdriver, &gmode, "");
 errorcode = graphresult();
 if (errorcode != grOk)  /* an error occurred */
 {
   printf("Graphics error: %s\n", grapherrormsg(errorcode));
   printf("Press any key to halt:");
   getch();
 }
}
Example #16
0
/*
 * Initializeaza modul grafic folosing macroul BGI.
 */
void initialize_graphic_mode()
{
    int gd = DETECT, gm, err;

    initgraph(&gd, &gm, BGI);
    if ((err = graphresult()) != grOk)
    {
        printf("Eroare: %s", grapherrormsg(err));
        getch();
        exit(1);
    }
}
Example #17
0
void main(void)
 {
   int  dr = DETECT, mode, errorcode;
   int r1,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12;
   clrscr();
   initgraph(&dr, &mode, "f:\\comp\\c\\bc\\bgi");
   errorcode = graphresult();
   if (errorcode != 0) {
   printf(" graphics Error :%s\n", grapherrormsg(errorcode));
   exit(1);
   }
/*   for(r1=0;r1<15;++r1){*/

   setcolor(4);
   setbkcolor(1);
   i2=0;
   i1=30;
  /* i3=100;
   i4=100;
   i5=150;
   i6=350;
   i7=390;
   i8=400;
   i9=500;
   i10=220;
   i11=340;
   i12=0;         */


  while(i2<220) {

    ++i2;
/*   ++i3;
   --i4;
   ++i5;
   --i6;
   --i7;
   --i8;
   --i9;
   ++i12;
   cleardevice();
int i[12] = {i1,i2,i3,i4,i5,i6,i7,i8,i9,i10 };
   drawpoly(6, i);    */
   cleardevice();
   outtextxy(i1,i2,     "                      ö‘þ‘•");
   outtextxy(i1,(i2+40),"¢þøª üõ š¤‘¡ ô—¨þ¨ ¥� öø÷î�");
   outtextxy(i1,(i2+80),"                 ¤�¢úð÷ �¢¡");
   settextstyle(0,0,2);
    }

   getch();
   closegraph();
   }
Example #18
0
/* 初始化图形模式 */
void InitialGraphics(void)
{
	int graphdriver=VGA,graphmode=VGAHI;
	int errorcode;
	initgraph(&graphdriver,&graphmode,"");
	errorcode=graphresult();
	if(errorcode!=grOk)
	{
		printf("Graphics error:%s\n",grapherrormsg(errorcode));
		GoodBye();
	}
}
Example #19
0
void changetextstyle(int font, int direction, int charsize)
{
  int ErrorCode;

  graphresult();			/* clear error code		*/
  settextstyle(font, direction, charsize);
  ErrorCode = graphresult();		/* check result 		*/
  if( ErrorCode != grOk ){		/* if error occured		*/
	closegraph();
	printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
	exit( 1 );
  }
}
Example #20
0
int main() {
	int unidad = -1,modo,error;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	error = graphresult();
	if (error < 0) {
		printf ("Error -> ");
		getch();
		printf (" %d %s\n",error, grapherrormsg (error) );
		getch();
		exit (1);
	}
	return 0;
}
Example #21
0
void loadgraph() 
{ 
  clrscr(); 
  int driver = DETECT, mode, errorcode; 
  initgraph(&driver, &mode, "c:\\tc\\bgi"); 
  errorcode = graphresult(); 
  if (errorcode != grOk) 
     { 
    cout<<"Graphics error: \n"<<(grapherrormsg(errorcode)); 
    cout<<"Press any key to halt:"; 
    getch(); 
    exit(1); 
    } 
} 
Example #22
0
 cInterface()
	{
	 gdriver = DETECT;
	 initgraph(&gdriver, &gmode, "G:\\MyFavor\\TC\\BGI");
	 errorcode = graphresult();
	 if (errorcode != grOk)  /* an error occurred */
		{
		 printf("Graphics error: %s\n", grapherrormsg(errorcode));
		 printf("Press any key to halt:");
		 getch();
		 exit(1); /* terminate with an error code */
		}
	 right=getmaxx();
	 bottom=getmaxy();
	} 
Example #23
0
File: csort.c Project: eposts/Rich
void Initialize( void )
{
 int    GraphDriver; /* 图形设备驱动   */
 int    GraphMode;   /* 图形模式值      */
 int    ErrorCode;   /* 出错代码  */

 GraphDriver = DETECT;              /* 自动检测显示设备类型 */
 initgraph( &GraphDriver, &GraphMode, "" );
 ErrorCode = graphresult();   /* 读取初始化的结果*/
 if( ErrorCode != grOk )      /* 如果在初始化的过程中发生错误  */
   {
    printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
    exit( 1 );
   }

}
Example #24
0
void InstallGraph(void)
{
   int gd=DETECT,gm;
   int errorcode;
   char*errormsg;
   initgraph(&gd,&gm,"");
   errorcode=graphresult();
   errormsg=grapherrormsg(errorcode);
   if(errorcode!=grOk)
   {
      printf("Graphics error:%s\n",errormsg);
      printf("Press any key to exit.\n");
      getch();
      exit(1);
   }
}
Example #25
0
pacova::pacova():pagina_atual(0)
{
  cout << "Utilit�rio de Tela Pacova 1.0\n";

  char erro = inicializa_modo_grafico();

  if (erro)
  {
    cout << "Erro ao inicializar modo Gr�fico: " << grapherrormsg(erro) << "\n";
    cout << "Pressione qualquer tecla para finalizar...";
    bip();
    pause();
  }

  setactivepage(0);
  setvisualpage(0);
}
Example #26
0
void
plD_init_vga(PLStream *pls)
{
	int driver;

	 pls->termin = 1;            /* is an interactive terminal */
	 pls->icol0 = 1;
	 pls->width = 1;
	 pls->bytecnt = 0;
	 pls->page = 0;
	 pls->graphx = TEXT_MODE;
	 pls->plbuf_write = 1;

	 if (!pls->colorset)
	pls->color = 1;

/* Set up device parameters */

#ifdef TSENG4
  driver =installuserdriver ("TSENG4", Tseng4Mode);
  errorcode = graphresult();

  errorcode = graphresult();
  if (errorcode != grOk) {
	 printf("Graphics error: %s\n", grapherrormsg(errorcode));
	 printf("Press any key to halt:");
	 getch();
	 exit(1); /* terminate with an error code */
  }
#endif

	 bgi_graph(pls);

	 dev->xold = UNDEFINED;
	 dev->yold = UNDEFINED;
	 dev->xmin = 0;
	 dev->xmax = getmaxx();
	 dev->ymin = 0;
	 dev->ymax = getmaxy();

	 plP_setpxl(2.5, 2.5);           /* Pixels/mm. */

	 plP_setphy((PLINT) 0, (PLINT) dev->xmax, (PLINT) 0, (PLINT) dev->ymax);

}
Example #27
0
int DGraphics::Init( int gmode )
{
 int gdriver = VGA,
     errorcode;

 gdriver=installuserdriver("SVGA256",NULL);
 initgraph(&gdriver, &gmode, "");

 if ( (errorcode = graphresult()) != grOk )
  {
    cout << "Error: Graphics - %s\n" << grapherrormsg(errorcode);
    return FALSE;
  }

 ActiveMode=gmode;

 return TRUE;
}
Example #28
0
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int style, midx, midy;
   int size = 1;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;

   settextjustify(CENTER_TEXT, CENTER_TEXT);

   /* loop through the available text styles */
   for (style=DEFAULT_FONT; style<=GOTHIC_FONT; style++)
   {
      cleardevice();
      if (style == TRIPLEX_FONT)
         size = 4;

      /* select the text style */
      settextstyle(style, HORIZ_DIR, size);

      /* output a message */
      outtextxy(midx, midy, fname[style]);
      getch();
   }

   /* clean up */
   closegraph();
   return 0;
}
Example #29
0
void initialize_graphics(int& max_x, int& max_y)
{
	/*
	initialize_graphics() function initializes the graphic enviroment.
	*/
	int gdriver = DETECT, gmode, errorcode;
	initgraph(&gdriver, &gmode, "E:\\tc\\bgi");
	/* read result of initialization */
	errorcode = graphresult();
	if (errorcode != grOk)  /* an error occurred */
	{
		printf("Graphics error:",grapherrormsg(errorcode));
		printf( "Press any key to halt:");
		getch();
		exit(1); /* terminate with an error code */
	}
	max_x = getmaxx();
	max_y = getmaxy();
}
Example #30
0
void ginit()
{
	/* 自動検出を要求 */
	int gdriver = DETECT, gmode, errorcode;

	/* グラフィックスシステムの初期化 */
	initgraph(&gdriver, &gmode, "c:\\bc4\bgi");

	/* 初期化の結果を取得 */
	errorcode = graphresult();

	if (errorcode != grOk)  /* エラーが発生したか? */
	{
		printf("Graphics error: %s\n", grapherrormsg(errorcode));
		printf("Press any key to halt:");
		getch();
		exit(1);             /* エラーとして終了 */
	}
}