Esempio n. 1
0
int main() {
	int unidad = 0,modo,n;
	void *getmemoria(int),*p;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	n = imagesize (0,0,8,8);

	if (n == 0) {
		outtextxy (0,10,"n es cero");
		return 1;
	}
	if (graphresult() == -11) {
		outtextxy (0,20,"Error en imagesize() ");
		return 2;
	}
   outtextxy(0,0,"C");
	p = getmemoria (n);
	getimage (0,0,8,8,p);
	getch();
	setpalette (3,RED);
	setcolor (3);
	outtextxy(10,10,"C");
	getch();
	putimage (0,250,p,COPY_PUT);
	getch();
	closegraph();
	return 0;
}
Esempio n. 2
0
int main() {
	int unidad = 0,modo,n;
	char s[10];
	void *getmemoria(int),*p;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	n = imagesize (20,30,40,130);
	if (n == 0) {
		outtextxy (0,10,"n es cero");
		return 1;
	}
	if (graphresult() == -11) {
		outtextxy (0,20,"Error en imagesize() ");
		return 2;
	}
	itoa(n,s,10);
	outtextxy (0,0,"Numero de bytes: ");
	outtextxy (136,0,s);
	p = getmemoria (n);		// No esta dentro de las librerias del c++

	//   ... Procesos adicionales

	delete p;

	// Es obligatorio liberar la memoria asignada

	getch();
	closegraph();
	return 0;
}
Esempio n. 3
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 );
  }
}
Esempio n. 4
0
int main() {
	{
		int unidad = 0,modo;
		mouse.Inicializar();
		initgraph (&unidad,&modo,"c:\\bc\\bgi");
		if (graphresult() != 0) {
			cout << "Error al tratar de pasar al modo grafico\n";
			getch();
			return 1;
		}
		mouse.Mostrar();
		setcolor(BLUE);
		Ventana ObjetoV1 (10,20,250,170,0, 0);
		ObjetoV1.DibujarVentana();
		Ventana *ObjetoV2 = new Ventana(40,50,280,200,1,1);
		ObjetoV2->DibujarVentana();
		mouse.LibBotones();
		ObjetoV2->Interactuar();
		delete ObjetoV2;
		mouse.LibBotones();
		ObjetoV1.Interactuar();
	}
	closegraph();
	return 0;
}
Esempio n. 5
0
int main(int argc, char *argv[])
   {
   int   i;
   int   gdriver = DETECT, gmode;
   char  *name = "H--C";

#ifdef   BGI_DIRECTORY
   initgraph(&gdriver, &gmode, BGI_DIRECTORY);
#else
   // use of linked driver allows demo to run without knowing BGI location
   if (registerbgidriver(EGAVGA_driver)<0)
      return fprintf(stderr, "registerbgidriver failed\n")!=0;
   initgraph(&gdriver, &gmode, "");
#endif
   if (graphresult()!=grOk)
      return fprintf(stderr, "%s: initgraph failed\n", argv[0])!=0;
   setfillstyle(SOLID_FILL, BLACK);
   if (argc>1)
      strncpy(name, argv[1], 4);
   for (i=12; i>5; i--)
      {
      sprintf(&name[3], "%1X", i);
      showFont(name);
      }
   closegraph();
   return 0;
   }
Esempio n. 6
0
init_graph (int driver)
{
#ifdef LOWLEVEL
	reg.h.ah = 0;
        reg.h.al = driver;
        int86 (0x10, &reg, &reg);
#else
#ifdef TEST
#else
int status;
int mode;
static int done = 0;
	if (done)
		cleardevice();
	/* restorecrtmode(); */
	else
	{
	driver = HERCMONO;
	mode = HERCMONOHI;
	initgraph (&driver, &mode, "");
	status = graphresult ();
	if (status != grOk)
		printf ("Erreur initgraph %d 0x%X\n", status, status);
	}
	done = 1;

#endif
#endif
}
Esempio n. 7
0
int main() {
	int unidad = 0,modo,i;
	char s[10];

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}

	outtext ("UNIVERSIDAD");
	getch();
	setpalette (15,YELLOW);				// Cambia de color a UNIVERSIDAD
	getch();
	i = getmaxcolor();         		// Almacena en i 15
	itoa (i,s,10);
	outtextxy (0,10,s);     			// Escribe 15
	getch();
	i = i - 4;
	setcolor (--i);						// Cambia el calor a LIGHTGREEN  (10)
												// Pero no cambia nada sobre el video

	outtextxy (0,20,"UNIVERSIDAD");	// Escribe UNIVERSIDAD en LIGHTGREEN
	getch();
	return 0;
}
Esempio n. 8
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
    {
Esempio n. 9
0
int main() {
	int unidad = 0,modo;
	char p[8] = { 0xAB,0xAA,0xAC,0xAA,0x12,0x34,0x45,0x56 };

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setpalette (3,RED);
	setcolor(3);
	rectangle (100,100,getmaxx(),getmaxy() );
	getch();
	setpalette (4,GREEN);
	setcolor(4);
	rectangle (50,50,200,300);
	getch();
	setpalette (15,BLUE);
	setfillpattern (p,15);
	floodfill (101,101,4);
	getch();
	closegraph();
   return 0;
}
Esempio n. 10
0
int main() {
	int unidad = 0,modo;
	struct textsettingstype p;
	char sfuente[10],sdireccion[10],stamano[10],shoriz[10],svert[10];

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	settextjustify (LEFT_TEXT,CENTER_TEXT);
	settextstyle (GOTHIC_FONT,HORIZ_DIR,3);
	gettextsettings (&p);
	itoa (p.font,sfuente,10);
	itoa (p.direction,sdireccion,10);
	itoa (p.charsize,stamano,10);
	itoa (p.horiz,shoriz,10);
	itoa (p.vert,svert,10);
	settextstyle (DEFAULT_FONT,HORIZ_DIR,0);
	outtextxy (0,10,sfuente);
	getch();
	outtextxy (0,20,sdireccion);
	getch();
	outtextxy (0,30,stamano);
	getch();
	outtextxy (0,40,shoriz);
	getch();
	outtextxy (0,50,svert);
	getch();
	closegraph();
	return 0;
}
Esempio n. 11
0
main()
{
int driver, mode;
int status;
char buf[1000];
	driver = DETECT;
	mode = VGAHI;

	initgraph (&driver, &mode, "");
	status = graphresult ();
	if (status != grOk)
	{
		printf ("Erreur initgraph %d 0x%X\n", status, status);
		return;
	}

	putpixel (120, 130, 1);
	{
	int i;
		for (i=0; i<150; i++)
		{
			putpixel (i, i, i*16/150);
		}
	}

	interf ();

	gets (buf);
	sleep (1);
	restorecrtmode ();
	printf ("status = %d\n", status);
}
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();

}
Esempio n. 13
0
int main() {
	int unidad = 0,modo,menor,mayor,i;
	char *p;
	char *s[5];


	for (i=0; i < 5; i++)
		s[i] = new char [20];


	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		printf ("Error al tratar de pasar al modo grafico\n");
		getch();
		return 1;
	}

	getmoderange (unidad,&menor,&mayor);


	for (i = menor; i <= mayor; i++) {
	  p = getmodename (i);
	  strcpy (s[i],p);
	}

	for (i = menor; i <= mayor; i++) {
		outtextxy (0,i * 10, s[i] );
	}

	getch();
	closegraph();
	for (i=0; i < 5; i++)
		delete s[i];
	return 0;
}
Esempio n. 14
0
int main() {
	int x,y,i,j,n,unidad,modo;
	char sx[10],sy[10],sn[10];


	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setpalette (3,YELLOW);
	setcolor (3);
	settextstyle (GOTHIC_FONT,HORIZ_DIR,3);
	i = textheight ("E");
	j = textwidth ("ESTRUCTURAS DE DATOS EN PASCAL");
	itoa(i,sx,10);
	itoa(j,sy,10);
	settextstyle (DEFAULT_FONT,HORIZ_DIR,1);
	char *p;
	int k = strlen (sx) +  strlen (sy) + 2;
	p = new char [k];
	strcpy (p,sx);
	strcat (p," ");
	strcat (p,sy);
	outtext (p);
	delete p;
	getch();
	closegraph();
	return 0;
}
Esempio n. 15
0
void InitGraphics() {
   int gdriver = VGA, gmode=VGAHI, errorcode;
   initgraph(&gdriver, &gmode, "");
   errorcode = graphresult();
   if (errorcode != grOk)
      Error("Graphics error: %s\n", grapherrormsg(errorcode));
}
Esempio n. 16
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;
}
Esempio n. 17
0
static void Initplot(void) {
#if !defined(__GO32__)
	registerfarbgidriver(EGAVGA_driver_far);
	registerfarbgidriver(CGA_driver_far);
	registerfarbgidriver(Herc_driver_far);
	registerfarbgifont(triplex_font_far);
#endif

	graphdev = DETECT;
	initgraph(&graphdev, &graphmode,"c:\\bc\\bgi");
	{int err;
		graphdev=1;
		err = graphresult();
		if (err != grOk) {
hoc_execerror("Error in initializing graphics adaptor\n", (char *)0);
		}
		xres = (double)(getmaxx()+1);
		yres = (double)(getmaxy()+1);
		grx_txt_clear();
		return;
	}
	if (graphdev > 0) {
		xres = (double)(getmaxx()+1);
		yres = (double)(getmaxy()+1);
		restorecrtmode();
	} else {
hoc_execerror("Error in initializing graphics adaptor\n", (char *)0);
	}
}
Esempio n. 18
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;
}
Esempio n. 19
0
int main()
{
	/*request autodetection*/
	int gdriver=DETECT, gmode, errcode;
	int midx, midy;
	int stangle=4, endangle=135;
	int radius=100;

	/* intialize graphics and local variables */
	initgraph(&gdriver,&gmode, NULL);
	/* read result of initialization */
	errcode=graphresult();
	if (errcode!=grOK) {
	printf("Graphs error");
	getch();
	exit(1);
	}
	midx=getmaxx()/2;
	midy=getmaxy()/2;
	setcolor(getmaxcolor());

	arc(midx,midy,stangle,endangle,radius);
	getch();
	closegraph();
	return 0;
}
//inicia o grafico
int inicia_grafico()
{
    int gdriver = DETECT, gmode;
    initgraph(&gdriver, &gmode, "c:\\borlandc\\bgi");

    return graphresult();
}
Esempio n. 21
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;
}
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;
}
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();
    }
}
Esempio n. 24
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);

}
Esempio n. 25
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;
}
Esempio n. 26
0
void inicializar_modo (void) /* Inicializar el modo gr fico */
{
	int controlador = DETECT, modo, codigo_error;

	installuserdriver ("Svga256", DetectarVGA256);

	initgraph (&controlador, &modo, ""); /* Inicializar modo grafico */
	mostrar_error (codigo_error = graphresult ()); /* Verificar que no ha sucedido ning£n error en la inicializaci¢n grafica */
}
Esempio n. 27
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;
}
Esempio n. 28
0
void  graph_view(void)
{
   int  graphdriver = DETECT, graphmode;
   int  reading, value;
   int  maxx, maxy, left, top, right, bottom, width;
   int  base;                          /* zero x-axis for graph */
   int  vscale = 1.5;       /* value to scale vertical bar size */
   int  space = 10;                     /* spacing between bars */

   char fprint[20];               /* formatted text for sprintf */

   initgraph(&graphdriver, &graphmode, "..\\bgi");
   if (graphresult() < 0)           /* make sure initialized OK */
      return;

   maxx  = getmaxx();              /* farthest right you can go */
   width = maxx /(READINGS + 1); /* scale and allow for spacing */
   maxy  = getmaxy() - 100;              /* leave room for text */
   left  = 25;
   right = width;
   base  = maxy / 2;              /* allow for neg values below */

   for (reading = 0; reading <  READINGS; reading++)
   {
      value = temps[reading] * vscale;
      if (value > 0)
      {
         top = base - value;            /* toward top of screen */
         bottom = base;
         setfillstyle(HATCH_FILL, 1);
      }
      else
      {
         top = base;
         bottom = base - value;      /* toward bottom of screen */
         setfillstyle(WIDE_DOT_FILL, 2);
      }
      bar(left, top, right, bottom);
      left  +=(width + space);       /* space over for next bar */
      right +=(width + space);        /* right edge of next bar */
   }

   outtextxy(0, base, "0 -");
   outtextxy(10, maxy + 20, "Plot of Temperature Readings");
   for (reading = 0; reading < READINGS; reading++)
   {
      sprintf(fprint, "%d", temps[reading]);
      outtextxy((reading *(width + space)) + 25, maxy + 40, fprint);
   }

   outtextxy(50, maxy+80, "Press any key to continue");

   getch();                               /* Wait for a key press */

   closegraph();
}
Esempio n. 29
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();
}
Esempio n. 30
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);
    }
}