Exemplo n.º 1
0
void main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy,i,j,f;
   float ar,rr,a;
   float x [4],y[4];

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

   /* read result of initi
   alization */
   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 */
   }
   setcolor(13);
   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   ar=6.283185307/d;
   rr=midy;
   for(f=1;f<=d;f++)
   {
   x[0]=midx;
   y[0]=midy;
   a=(f-1)*ar;
   x[1]=cos(a)*rr+midx;
   y[1]=sin(a)*rr+midy;
   a=f*ar;
   x[2]=cos(a)*rr+midx;
   y[2]=sin(a)*rr+midy;
   x[3]=x[0];
   y[3]=y[0];
   for(j=1;j<=r;j++)
   {
      for(i=0;i<3;i++)
      {
       line(x[i],y[i],x[i+1],y[i+1]);
      }
      if(f%2==1)
      {
	for(i=3;i>0;i--)
	{
	x[i]+=(x[i-1]-x[i])/z;
	y[i]+=(y[i-1]-y[i])/z;
	}
      x[0]=x[3];
      y[0]=y[3];
      }
   else
   {
   for(i=0;i<3;i++)
   {
   x[i]+=(x[i+1]-x[i])/z;
   y[i]+=(y[i+1]-y[i])/z;
   }
   x[3]=x[0];
   y[3]=y[0];
   }//end if else
   }//end for j
   }
   getch();
   closegraph();
   }
Exemplo n.º 2
0
void
colorcombo_init ()
{
  if (!flag_basiccolorname)
    {
      flag_basiccolorname = "darkgreen";
    }

#define setcolor(idx, cname)  \
  colorcombo[idx].name = # cname; colorcombo[idx].color = cname;

  setcolor (0, darkgreen);
  setcolor (1, darkorange);
  setcolor (2, yellowgreen);
  setcolor (3, seagreen);
  setcolor (4, darkskyblue);
  setcolor (5, indianred);
  setcolor (6, maroon);
  setcolor (7, khaki);
  setcolor (8, seagreen);
  setcolor (9, chocolate);
  setcolor (10, darkorchid);

  set_basiccolorpixel (flag_basiccolorname);
}
Exemplo n.º 3
0
void monitor_tools(int n,int t)
{
	getmousepos(&button,&mousex,&mousey);
	for(;mousey<20;getmousepos(&button,&mousex,&mousey))
	{
	       if((mousex/20>0)&&(mousex/20)<=n&&(mousex/20)!=button_track)
	       {
			button_track=mousex/20;
			top_panel_buttons(n,button_track,2);
			if(t==0)
			{
				hidemouseptr();
				settextstyle(0,0,1);
				if(cur_color==0)
					setcolor(WHITE);
				else
					setcolor(BLACK);
				hover_text(mousex/20);
				showmouseptr();
			}
	       }
	       else if(mousex<20&&button==1&&t!=0)
	       {
			cur_panel=0;
			t=0;
			cur_style=1;
			n=tool_but_num;
			button_hover(2,2,18,18);
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
		   }
		   else if(t==0&&mousex>619&&button==1)
			{
				button_hover(620,2,638,18);
				ask_exit();
			}
	       else if(((mousex/20)==0||(mousex/20>(n+1)))&&button_track!=-1)
			{
			button_track=-1;
			top_panel_buttons(n,0,2);
			if(t==0)
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
			else if(t==1)
			button_click((2+cur_style*20),2,(18+cur_style*20),18);
			}
		   if((mousex/20>0)&&(mousex/20)<=n&&button==1)
	       {
			if(t==0)
			{
			if(button_track!=18)
			cur_tool=button_track;
			button_hover((2+button_track*20),2,(18+button_track*20),18);
			if(button_track==18)
			{
			cur_panel=2;
		   draw_color();
			}
			draw_style();
			break;
			}
			else
			{
			cur_style=button_track;
			button_hover((2+cur_style*20),2,(18+cur_style*20),18);
			}
	       }

	}
}
Exemplo n.º 4
0
Arquivo: ui.c Projeto: notadecent/uTox
static void drawfriendreq(int x, int y, int width, int height)
{
    setcolor(C_TITLE);
    setfont(FONT_SELF_NAME);
    drawstr(LIST_RIGHT + SCALE * 5, SCALE * 10, "Friend Request");
}
Exemplo n.º 5
0
Arquivo: ui.c Projeto: notadecent/uTox
static void drawsettings(int x, int y, int width, int height)
{
    setcolor(C_TITLE);
    setfont(FONT_SELF_NAME);
    drawstr(LIST_RIGHT + SCALE * 5, SCALE * 10, "User Settings");
}
Exemplo n.º 6
0
void MelhorProvaVVM(int old, int nnew)
   {
   register int     i, ncol, nlin,
		       escala, y0,
			   y1, y2;
   int             y_ini0, y_ini1;
   int                        cor;
   int               janelaAtiva;

   float    far              *apt;
   float    far           *aptaux;
   register float  flux, sum_flux;
   float                   sum[4];

   char                     *p_ch;
   char                  setaE[2],
			 setaD[2];




   setaE[0] = 27;
   setaD[0] = 26;
   setaE[1] = setaD[1] = '\0';

#ifndef MODO_VGA_640X480_HIG
   setactivepage(1);
   setvisualpage(1);
#else   MODO_VGA_640X480_HIG
   LimpaTela();
#endif  MODO_VGA_640X480_HIG

   setviewport ( 0, 0, MAXX, MAXY, 1 );
   clearviewport ();

   cor = getcolor();
   setcolor (bea_color[12]);
   CriaJanelaGrafica(   MANOB1,
			0,
			0,
			(int) ((MAXX * 49L)/100),
			(int) ((MAXY * 90L)/100),
			0, "MANOBRA %02d", old   );

   clearviewport();

   CriaJanelaGrafica(   MANOB2,
			(int) ((MAXX * 51L)/100),
			0,
			MAXX,
			(int) ((MAXY * 90L)/100),
			0,
			"MANOBRA %02d", nnew     );

   clearviewport();
   setcolor (cor);

   AtivaJanelaGrafica(MANOB1,0);
   setcolor ( bea_color[14] );

   getviewsettings (&vp);

   DesenhaEixos( DELTA_X(2), DELTA_X(96),
		 DELTA_Y(4), DELTA_Y(98),
		 DELTA_X(6), DELTA_Y(22),
		 DELTA_X(22),DELTA_Y(14) );

   sum_flux         =         0.0;
   escala           = DELTA_Y(14);
   coluna           = DELTA_X( 8);
   y0 = y_ini0      = DELTA_Y(76);
   y2 = y1 = y_ini1 = DELTA_Y(92);

   apt              =    inicVVM2;
   aptaux           = inicVVM2Int;
   sum[0] = sum[1]  =
   sum[2] = sum[3]  =         0.0;


   ScalaVVMBetter();


   for (   i = 0;
	   (*apt != FIM_1) &&
	   (apt < inicVVM2 + NUMMAXPONTOSINF);
	   apt++, i++    )
      {
      flux      = *aptaux; aptaux++;

#ifdef VVM_ALCAP_
      sum_flux += flux / SampleRatio;

      sum[0] = (.01 * sum_flux) + (.19 * sum[1]) +
	       (.30 *   sum[2]) + (.50 * sum[3]);

      sum[3] = sum[2];
      sum[2] = sum[1];
      sum[1] = sum[0];
#else  VVM_ALCAP_
      sum_flux = sum_flux;
      flux = flux;
      y_ini1 = y_ini1;
      y0 = y0;
      y1 = y1;
      y2 = y2;
#endif  VVM_ALCAP_

      ncol = (int) ( (((long) i) * DELTA_X(88))/2400 + DELTA_X( 8) );

      if ( ncol != coluna )
	 {
	 cor = getcolor();

	 /* -------------------------- */
	 /* Tracado do Volume Expirado */
	 /* -------------------------- */
	 nlin = (int) ((y_ini0 - (((long) escala ) * (*apt))/10));

	 moveto(coluna, y0);
	 lineto( coluna, nlin );
	 y0 = nlin;

#ifdef VVM_ALCAP_
	 setcolor (bea_color[ 7]);

	 /* ----------------------------- */
	 /* Tracado do Volume (Invertido) */
	 /* ----------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum_flux))/2));

	 moveto(coluna, y1);
	 lineto( coluna, nlin );
	 y1 = nlin;

	 setcolor (bea_color[11]);

	 /* -------------------------------------------------- */
	 /* Tracado Valor Medio filtrado do Volume (Invertido) */
	 /* -------------------------------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum[0]))/2));
	 moveto(coluna, y2);
	 lineto( coluna, nlin );
	 y2 = nlin;
#endif VVM_ALCAP_

	 setcolor (cor);

	 coluna = ncol;
	 }

      }

   outtextxy(DELTA_X(10) , DELTA_Y(10),
	     "Param  Teor    Calc      %");

   cor = getcolor ();

   setcolor (bea_color[15]);

   gprintf(  DELTA_X(10), DELTA_Y(11) + CharH,
	     "VVM    %6.2f  %6.2f  %4.0f",
	     VentVolMaxteorico,
	     VentVolMax2,
	     (VentVolMaxpercen2 + 0.5)  );

#ifdef VVM_ALCAP_
   gprintf  (DELTA_X(10), DELTA_Y(12) + 2 * CharH,
	     "ALCAP    --   %7.2f    - ",
	     VolAlcaponado2);
#endif VVM_ALCAP_



   /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */


   setcolor (cor);

   AtivaJanelaGrafica(MANOB2,0);
   setcolor ( bea_color[14] );

   getviewsettings (&vp);

   DesenhaEixos( DELTA_X(2), DELTA_X(96),
		 DELTA_Y(4), DELTA_Y(98),
		 DELTA_X(6), DELTA_Y(22),
		 DELTA_X(22),DELTA_Y(14) );

   sum_flux         =         0.0;
   escala           = DELTA_Y(14);
   coluna           = DELTA_X( 8);
   y0 = y_ini0      = DELTA_Y(76);
   y2 = y1 = y_ini1 = DELTA_Y(92);

   apt              =    inicVVM1;
   aptaux           = inicVVM1Int;
   sum[0] = sum[1]  =
   sum[2] = sum[3]  =         0.0;


   ScalaVVMBetter();


   for (   i = 0;
	   (*apt != FIM_1) &&
	   (apt < inicVVM1 + NUMMAXPONTOSINF);
	   apt++, i++    )
      {
      flux      = *aptaux; aptaux++;
#ifdef VVM_ALCAP_
      sum_flux += flux / SampleRatio;

      sum[0] = (.01 * sum_flux) + (.19 * sum[1]) +
	       (.30 *   sum[2]) + (.50 * sum[3]);

      sum[3] = sum[2];
      sum[2] = sum[1];
      sum[1] = sum[0];
#endif VVM_ALCAP_

      ncol = (int) ( (((long) i) * DELTA_X(88))/2400 + DELTA_X( 8) );

      if ( ncol != coluna )
	 {
	 cor = getcolor();

	 /* -------------------------- */
	 /* Tracado do Volume Expirado */
	 /* -------------------------- */
	 nlin = (int) ((y_ini0 - (((long) escala ) * (*apt))/10));

	 moveto(coluna, y0);
	 lineto( coluna, nlin );
	 y0 = nlin;

#ifdef VVM_ALCAP_
	 setcolor (bea_color[ 7]);

	 /* ----------------------------- */
	 /* Tracado do Volume (Invertido) */
	 /* ----------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum_flux))/2));

	 moveto(coluna, y1);
	 lineto( coluna, nlin );
	 y1 = nlin;

	 setcolor (bea_color[11]);

	 /* -------------------------------------------------- */
	 /* Tracado Valor Medio filtrado do Volume (Invertido) */
	 /* -------------------------------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum[0]))/2));
	 moveto(coluna, y2);
	 lineto( coluna, nlin );
	 y2 = nlin;
#endif VVM_ALCAP_

	 setcolor (cor);

	 coluna = ncol;
	 }

      }

   outtextxy(DELTA_X(10) , DELTA_Y(10),
	     "Param  Teor    Calc      %");

   cor = getcolor ();

   setcolor (bea_color[15]);

   gprintf(  DELTA_X(10) , DELTA_Y(11) + CharH,
	     "VVM    %6.2f  %6.2f  %4.0f",
	     VentVolMaxteorico,
	     VentVolMax,
	     (VentVolMaxpercent + 0.5)  );

#ifdef VVM_ALCAP_
   gprintf  (DELTA_X(10), DELTA_Y(12) + 2 * CharH,
	     "ALCAP    --   %7.2f    - ",
	     VolAlcaponado);
#endif VVM_ALCAP_

   setcolor (cor);

   DesativaJanelaGrafica(MANOB2);

   cor = getcolor();
   setcolor (bea_color[12]);

   p_ch = "ESCOLHA DA MELHOR MANOBRA (%1s %1s)";

   gprintf((MAXX - textwidth(p_ch))/2,
	   (int) ((MAXY * 95L)/100),
	   p_ch,
	   setaE,
	   setaD);

   AtivaJanelaGrafica(MANOB1,0);
   setcolor ( bea_color[14] );
   janelaAtiva = 0;
   do {
      LimpaBufferTeclado();
      sc.c = LeTeclado();
      if (sc.ch[0] == 0)
	 if (sc.ch[1]==75 || sc.ch[1]==77)
	    {
	    DesativaJanelaGrafica(janelaAtiva);
	    janelaAtiva = (janelaAtiva + 1) % 2;
	    AtivaJanelaGrafica(janelaAtiva,0);
	    setcolor ( bea_color[14] );
	    }
      } while(sc.ch[0] != ENTER);

   setcolor (cor);

   DesativaJanelaGrafica(janelaAtiva);

   if (janelaAtiva == 0)
      {
      inicVVM1 = inicVVM2;
      inicVVM1Int = inicVVM2Int;
      VentVolMax = VentVolMax2;
      VentVolMaxpercent = VentVolMaxpercen2  ;
      VolAlcaponado = VolAlcaponado2;
      }
   else    ManobVVMAtiva = nnew;

#ifndef MODO_VGA_640X480_HIG
   setactivepage(0);
   setvisualpage(0);
#endif  MODO_VGA_640X480_HIG
   }        /* MelhorProvaVVM */
Exemplo n.º 7
0
void landing(){
	x = 0; 
	y = 0;		
	cleardevice();
	while( x < 500 ){  
		cleardevice();
		line( 280, 304, 639, 304);
		x++;
		setcolor(9);
		if( x < 200 ){
			y += 1;
			//flight outline
			line( x, y, x+20, y+20 );
			line( x, y, x, y+40 );
			line( x+20, y+20, x+80, y+20 );
			line( x+80, y+20, x+100, y+40 );
			line( x, y+40, x+100, y+40 );
			floodfill( x+75, y+27, 9);
			
			//inner rectangle
			setcolor(10);	
			rectangle( x+70, y+24, x+80, y+30 );
			floodfill( x+75, y+27, 10);
				
			
		}

		else if( x < 250 ){
			y += 1;
			line( x, y, x+20, y+20 );
			line( x, y, x, y+40 );
			line( x+20, y+20, x+80, y+20 );
			line( x+80, y+20, x+100, y+40 );
			line( x, y+40, x+100, y+40 );
			floodfill( x+75, y+27, 9);
			
			//inner rectangle
			setcolor(10);	
			rectangle( x+70, y+24, x+80, y+30 );
			floodfill( x+75, y+27, 10);
				
		
			//wheel
			line(x+30, y+40, x+20, y+44 );
			line(x+80, y+40, x+70, y+44 );
			setcolor(125);
			circle( x+25, y+44, 3);
			floodfill( x+25, y+44, 5);
			circle( x+75, y+44, 3);
			floodfill( x+75, y+44, 5);
		}	
		else{
			line( x, y, x+20, y+20 );
			line( x, y, x, y+40 );
			line( x+20, y+20, x+80, y+20 );
			line( x+80, y+20, x+100, y+40 );
			line( x, y+40, x+100, y+40 );
			floodfill( x+75, y+27, 9);
			
			//inner rectangle
			setcolor(10);	
			rectangle( x+70, y+24, x+80, y+30 );
			floodfill( x+75, y+27, 10);

			//wheel
			line(x+30, y+40, x+30, y+46 );
			line(x+80, y+40, x+80, y+46);
			setcolor(125);
			circle( x+30, y+50, 3);
			floodfill( x+30, y+50, 5);
			circle( x+80, y+50, 3);
			floodfill( x+80, y+50, 5);
		}
		delay(1);
	}
	x = 0;
	y = 0;
	printf("\n\n\t\tYour flight has been landed safely!!!!\n");
	getchar();
}
Exemplo n.º 8
0
void introd()
{
	int 	x,y,j,c,e,g,da;
	cleardevice();
	for(int ii=0;ii<=210;ii++)
	{
		sound(ii*10);
		c=random(12);
		setcolor(c);
		circle(320,240,ii);
		delay(50);
		setcolor(BLACK);
		circle(320,240,ii);
		nosound();
	}
	for(int r=0;r<=640;r+=50)
	{
		sound(r+40);
		setcolor(3);
		line(1,r,640,r);
		line(r,1,r,640);
		line(1,1,840,640);
		line(650,1,1,480);
		delay(80);
		nosound();
	}
		for(int t=0;t<=230;t+=8)
	{
		sound(t*10);
		setcolor(3);
		circle(320,240,t);
		setcolor(3);
		ellipse(320,240,0,360,t,80);
		ellipse(320,240,0,360,80,t);
		delay(80);
		nosound();
	}
	for(int z=0;z<80;z++)
	{
		sound(500+z);
		da=random(12);
		setcolor(da);
		circle(320,240,z);
		delay(50);
		nosound();
	}
	for(int q=80;q<340;q++)
	{
		sound(500*q);
		setcolor(0);
		circle(320,240,q);
		delay(50);
		nosound();
	}
		do
	{
		j=random(12);
		setcolor(j);
		settextstyle(3,0,6);
		outtextxy(250,330,"SRIRAM");
		outtextxy(240,80,"KARTHIK");
		settextstyle(3,1,6);
		outtextxy(150,140,"DEEPAK");
		outtextxy(430,140,"SRIHARI");
	}while(!kbhit());
	getch();
}
Exemplo n.º 9
0
main()

{
int i,ar,in,inp;

/*modo grafico*/
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,"..\\bgi");
errorcode=graphresult();
if (errorcode!= grOk)
	{
	printf("Error grafico: %s/n",grapherrormsg(errorcode));
	printf("Presione cualquier tecla:");
	getch();
	exit(1);
}


getch();




/* >>>>>>>>>>>>> INTRODUCCION <<<<<<<<<<<<<<<<*/

/* Background */
setcolor(1);
for (i=240; i>=0; i--)
	{
	/*delay(50);*/
	rectangle(i,i,getmaxx()-i,getmaxy()-i);
	}

setcolor(14);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxy()-2);
rectangle(3,3,getmaxx()-3,getmaxy()-3);
rectangle(4,4,getmaxx()-4,getmaxy()-4);
rectangle(5,5,getmaxx()-5,getmaxy()-5);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,420,"UNIVERSIDAD");
outtextxy(20,270,"SANTA");
outtextxy(20,115,"VINA");
outtextxy(614,420,"UNIVERSIDAD");
outtextxy(614,270,"SANTA");
outtextxy(614,115,"VINA");
setcolor(9);
rectangle(6,6,getmaxx()-6,getmaxy()-6);
rectangle(7,7,getmaxx()-7,getmaxy()-7);
rectangle(8,8,getmaxx()-8,getmaxy()-8);
rectangle(9,9,getmaxx()-9,getmaxy()-9);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
rectangle(11,11,getmaxx()-11,getmaxy()-11);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,365,"TECNICA");
outtextxy(20,237,"MARIA");
outtextxy(20,91,"DEL");
outtextxy(614,365,"TECNICA");
outtextxy(614,237,"MARIA");
outtextxy(614,91,"DEL");
setcolor(4);
rectangle(12,12,getmaxx()-12,getmaxy()-12);
rectangle(13,13,getmaxx()-13,getmaxy()-13);
rectangle(14,14,getmaxx()-14,getmaxy()-14);
rectangle(15,15,getmaxx()-15,getmaxy()-15);
rectangle(16,16,getmaxx()-16,getmaxy()-16);
rectangle(17,17,getmaxx()-17,getmaxy()-17);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,315,"FEDERICO");	
outtextxy(20,140,"SEDE");	
outtextxy(20,71,"MAR");	
outtextxy(614,315,"FEDERICO");	
outtextxy(614,140,"SEDE");	
outtextxy(614,71,"MAR");	
/*fin background */



setcolor(4);
for(i=0; i<=133; i++)rectangle(50+i,50+i,580-i,190-i);

/*line (col1,fila1,col2,fila2) */

setcolor(14);
line(50,50,50,190);
line(51,50,51,190);
line(52,50,52,190);

line(580,50,580,190);
line(581,50,581,190);
line(582,50,582,190);

line(50,50,580,50);
line(50,51,580,51);
line(50,52,580,52);

line(50,190,582,190);
line(50,191,582,191);
line(50,192,582,192);

setcolor(14);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(312,100,"PROGRAMACION DE SISTEMAS");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(312,160,"Proyecto Final");

setcolor(14);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,230,"Control de un Motor Paso a Paso");

settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,370,"ALUMNOS:");
outtextxy(320,390,"Rodrigo Augosto Cancino");
outtextxy(320,410,"Ivan Moyano Varas");

/* >>>>>>>>>>>>>> FIN INTRODUCCION <<<<<<<<<<<<<<<<<*/







/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
/*delay(9999);	delay(9999);*/
	delay(9000);








/* >>>>>> FUNCIONAMIENTO  <<<<<<<<<< */

/* Background*/
setcolor(1);
for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i);
setcolor(14);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxy()-2);
rectangle(3,3,getmaxx()-3,getmaxy()-3);
rectangle(4,4,getmaxx()-4,getmaxy()-4);
rectangle(5,5,getmaxx()-5,getmaxy()-5);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,420,"UNIVERSIDAD");
outtextxy(20,270,"SANTA");
outtextxy(20,115,"VINA");
outtextxy(614,420,"UNIVERSIDAD");
outtextxy(614,270,"SANTA");
outtextxy(614,115,"VINA");
setcolor(9);
rectangle(6,6,getmaxx()-6,getmaxy()-6);
rectangle(7,7,getmaxx()-7,getmaxy()-7);
rectangle(8,8,getmaxx()-8,getmaxy()-8);
rectangle(9,9,getmaxx()-9,getmaxy()-9);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
rectangle(11,11,getmaxx()-11,getmaxy()-11);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,365,"TECNICA");
outtextxy(20,237,"MARIA");
outtextxy(20,91,"DEL");
outtextxy(614,365,"TECNICA");
outtextxy(614,237,"MARIA");
outtextxy(614,91,"DEL");
setcolor(4);
rectangle(12,12,getmaxx()-12,getmaxy()-12);
rectangle(13,13,getmaxx()-13,getmaxy()-13);
rectangle(14,14,getmaxx()-14,getmaxy()-14);
rectangle(15,15,getmaxx()-15,getmaxy()-15);
rectangle(16,16,getmaxx()-16,getmaxy()-16);
rectangle(17,17,getmaxx()-17,getmaxy()-17);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,315,"FEDERICO");	
outtextxy(20,140,"SEDE");
outtextxy(20,71,"MAR");	
outtextxy(614,315,"FEDERICO");
outtextxy(614,140,"SEDE");	
outtextxy(614,71,"MAR");	
/*fin background */

setcolor(14);
for(i=0; i<=100; i++)rectangle(50+i,80+i,580-i,182-i);

setcolor(1);

/*line (col1,fila1,col2,fila2) */

line(55,85,55,175);
line(56,85,56,175);
line(57,85,57,175);

line(573,85,573,175);
line(574,85,574,175);
line(575,85,575,175);

line(55,85,575,85);
line(55,86,575,86);
line(55,87,575,87);

line(55,175,575,175);
line(55,176,575,176);
line(55,177,575,177);


setcolor(1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
outtextxy(300, 122, "DESCRIPCION DE FUNCIONAMIENTO");
outtextxy(300, 142, "DEL PROGRAMA");

setcolor(14);
settextjustify(CENTER_TEXT, CENTER_TEXT);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 2);
outtextxy(300, 220, "Programa disenado para controlar");
outtextxy(300, 245, "el movimiento de un motor paso a paso");
outtextxy(300, 270, "por intermedio de un Dip - Switch");
outtextxy(300, 295, "A continuacion se daran a conocer");
outtextxy(300, 320, "las posiciones del switch para");
outtextxy(300, 345, "distintos movimientos del motor.");

/*  >>>>>>>>>> FIN FUNCIONAMIENTO <<<<<<<<<<<<<<<<<*/






/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
/*delay(9999);	delay(9999);	delay(9999);*/
delay(9000);









/* >>>>>>>>>>>> PROGRAMA <<<<<<<<<<<<<<<<<<<<<<*/


while(1)
{

/* Background*/
setcolor(1);
for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i);
setcolor(14);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxy()-2);
rectangle(3,3,getmaxx()-3,getmaxy()-3);
rectangle(4,4,getmaxx()-4,getmaxy()-4);
rectangle(5,5,getmaxx()-5,getmaxy()-5);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,420,"UNIVERSIDAD");
outtextxy(20,270,"SANTA");
outtextxy(20,115,"VINA");
outtextxy(614,420,"UNIVERSIDAD");
outtextxy(614,270,"SANTA");
outtextxy(614,115,"VINA");
setcolor(9);
rectangle(6,6,getmaxx()-6,getmaxy()-6);
rectangle(7,7,getmaxx()-7,getmaxy()-7);
rectangle(8,8,getmaxx()-8,getmaxy()-8);
rectangle(9,9,getmaxx()-9,getmaxy()-9);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
rectangle(11,11,getmaxx()-11,getmaxy()-11);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,365,"TECNICA");
outtextxy(20,237,"MARIA");
outtextxy(20,91,"DEL");
outtextxy(614,365,"TECNICA");
outtextxy(614,237,"MARIA");
outtextxy(614,91,"DEL");
setcolor(4);
rectangle(12,12,getmaxx()-12,getmaxy()-12);
rectangle(13,13,getmaxx()-13,getmaxy()-13);
rectangle(14,14,getmaxx()-14,getmaxy()-14);
rectangle(15,15,getmaxx()-15,getmaxy()-15);
rectangle(16,16,getmaxx()-16,getmaxy()-16);
rectangle(17,17,getmaxx()-17,getmaxy()-17);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,315,"FEDERICO");	
outtextxy(20,140,"SEDE");	
outtextxy(20,71,"MAR");	
outtextxy(614,315,"FEDERICO");
outtextxy(614,140,"SEDE");
outtextxy(614,71,"MAR");	
/*fin background */

setcolor(4);
for(i=0; i<=100; i++)rectangle(50+i,80+i,580-i,182-i);

setcolor(15);

/*line (col1,fila1,col2,fila2) */

line(55,85,55,175);
line(56,85,56,175);
line(57,85,57,175);

line(573,85,573,175);
line(574,85,574,175);
line(575,85,575,175);

line(55,85,575,85);
line(55,86,575,86);
line(55,87,575,87);

line(55,175,575,175);
line(55,176,575,176);
line(55,177,575,177);

setcolor(14);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR,2);
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(315,130,"POSICIONES DEL DIP SWITCH");
settextjustify(LEFT_TEXT, CENTER_TEXT);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 1);
outtextxy(110, 240, " 0 0  El Motor esta detenido");
outtextxy(110, 260, " 0 1  El Motor avanza 36 grados y se detiene");
outtextxy(110, 280, " 1 0  El Motor avanza 18 grados y se detiene");
outtextxy(110, 300, " 1 1  El Motor retrocede 36 grados y se detiene");



in=inport(0x379);
inp=in&0xff;
printf("\n puerto de entrada: %x ",inp);

switch(inp){
case 0x7f : outportb(0x378,0x88);
	    outportb(0x378,0x44);
	    outportb(0x378,0x22);
	    outportb(0x378,0x11);
	    break;

case 0x6f : outportb(0x378,0x11);
	    outportb(0x378,0x22);
	    outportb(0x378,0x44);
	    outportb(0x378,0x88);
	    break;

case 0x77 : outportb(0x378,0x88);
	    outportb(0x378,0xcc);
	    outportb(0x378,0x44);
	    outportb(0x378,0x66);
	    outportb(0x378,0x22);
	    outportb(0x378,0x33);
	    outportb(0x378,0x11);
	    outportb(0x378,0x99);
	    break;

case 0x67 : outportb(0x378,0x11);
	    outportb(0x378,0x33);
	    outportb(0x378,0x22);
	    outportb(0x378,0x66);
	    outportb(0x378,0x44);
	    outportb(0x378,0xcc);
	    outportb(0x378,0x88);
	    outportb(0x378,0x99);
	    break;

default : break;
}

/* >>>>>>>>>>>> FIN PROGRAMA <<<<<<<<<<<<<<*/




setcolor(15);
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(500,450,"Otro giro (s/n)");


/*if (inp==0xff|inp==0xe7|inp==0xef|inp==0xf7)*/

ar=getch();
if (ar==110|ar==27)

{
	clrscr();
 	outportb(0x378,0x00);

	/* Background*/
setcolor(1);
for (i=0; i<=240; i++)rectangle(i,i,getmaxx()-i,getmaxy()-i);
setcolor(14);
rectangle(0,0,getmaxx(),getmaxy());
rectangle(1,1,getmaxx()-1,getmaxy()-1);
rectangle(2,2,getmaxx()-2,getmaxy()-2);
rectangle(3,3,getmaxx()-3,getmaxy()-3);
rectangle(4,4,getmaxx()-4,getmaxy()-4);
rectangle(5,5,getmaxx()-5,getmaxy()-5);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,420,"UNIVERSIDAD");
outtextxy(20,270,"SANTA");
outtextxy(20,115,"VINA");
outtextxy(614,420,"UNIVERSIDAD");
outtextxy(614,270,"SANTA");
outtextxy(614,115,"VINA");
setcolor(9);
rectangle(6,6,getmaxx()-6,getmaxy()-6);
rectangle(7,7,getmaxx()-7,getmaxy()-7);
rectangle(8,8,getmaxx()-8,getmaxy()-8);
rectangle(9,9,getmaxx()-9,getmaxy()-9);
rectangle(10,10,getmaxx()-10,getmaxy()-10);
rectangle(11,11,getmaxx()-11,getmaxy()-11);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,365,"TECNICA");
outtextxy(20,237,"MARIA");
outtextxy(20,91,"DEL");
outtextxy(614,365,"TECNICA");
outtextxy(614,237,"MARIA");
outtextxy(614,91,"DEL");
setcolor(4);
rectangle(12,12,getmaxx()-12,getmaxy()-12);
rectangle(13,13,getmaxx()-13,getmaxy()-13);
rectangle(14,14,getmaxx()-14,getmaxy()-14);
rectangle(15,15,getmaxx()-15,getmaxy()-15);
rectangle(16,16,getmaxx()-16,getmaxy()-16);
rectangle(17,17,getmaxx()-17,getmaxy()-17);
settextstyle(SMALL_FONT,VERT_DIR,4);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(20,315,"FEDERICO");	
outtextxy(20,140,"SEDE");	
outtextxy(20,71,"MAR");	
outtextxy(614,315,"FEDERICO");	
outtextxy(614,140,"SEDE");	
outtextxy(614,71,"MAR");
/*fin background */



	setcolor(15);
	settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
	settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(300,40,"UNIVERSIDAD TECNICA FEDERICO SANTA MARIA");
	outtextxy(340,60,"Sede Vina del Mar - CHILE");

	settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
	settextjustify(LEFT_TEXT,CENTER_TEXT);
	outtextxy(180,200,"ALUMNOS:");
	outtextxy(200,220,"* Rodrigo Augosto Cancino");
	outtextxy(200,240,"* Ivan Moyano Varas");

	settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
	settextjustify(LEFT_TEXT,CENTER_TEXT);
	outtextxy(180,280,"PROFESOR:");
	outtextxy(200,300,"* Jose Estay");

	settextstyle(SMALL_FONT,HORIZ_DIR,4);
	settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(310,430,"www.ivaninternet.com");
	outtextxy(310,440,"www.alumnos.utfsm.cl/~raugostc");
	outtextxy(310,450,">>>>TODOS LOS DERECHOS RESERVADOS<<<<");

	settextstyle(SANS_SERIF_FONT,VERT_DIR,2);
	settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(60,270,"CARRERA DE ELECTRONICA");
	outtextxy(40,270,"PROGRAMACION DE SISTEMAS");

	settextstyle(SANS_SERIF_FONT,VERT_DIR,2);
	settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(580,270,"CARRERA DE ELECTRONICA");
	outtextxy(600,270,"PROGRAMACION DE SISTEMAS");

	/*delay(9999);	delay(9999);	delay(60999);	delay(9999);*/
	/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
	/*delay(9999);	delay(9999);	delay(9999);	delay(9999);*/
	/*delay(9999);	delay(9999);*/
	delay(9000);

	break;
  	}
}
closegraph();
return(0);
}
void intro()
{
 int midx,midy,maxx,maxy,maxcol;
 midx = getmaxx() / 2;
 midy = getmaxy() / 2;
 maxx = getmaxx();
 maxy = getmaxy();
 maxcol= getmaxcolor();
 /* select the fill style */
 setfillstyle(10, maxcol);
 /* fill the screen with the pattern */
 bar(0, 0, maxx, maxy);
 rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
 rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;

 settextjustify(CENTER_TEXT, CENTER_TEXT);
 settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3); ///6 IS SIZE
 setcolor(4);
 outtextxy(315,125,"WELCOME");
 outtextxy(310,170,"TO");
 settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
 outtextxy(324,250,"EULER's PATH FINDER");
 getch();//delay(1200);

 clrscr();
 setfillstyle(10, maxcol);
 /* fill the screen with the pattern */
 bar(0, 0, maxx, maxy);
 setcolor(15);
 rectangle(midx/4,midy/4,7*midx/4+10,7*midy/4-30)  ;
 rectangle(midx/4-5,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
 settextjustify(CENTER_TEXT, CENTER_TEXT);
 settextstyle(TRIPLEX_FONT, HORIZ_DIR, 5);
 setcolor(4);
 outtextxy(330,200,"INTRODUCTION");
 settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);
 outtextxy(325,250,"(If you don't want an introduction press Esc)");
 if((getch())=='z')
  return;
 else
  {
   setfillstyle(10, maxcol);
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(4, HORIZ_DIR, 4);
   setcolor(4);
   outtextxy(315,100,"INTRODUCTION");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(350,160,"LEONARD EULAR was a Swiss mathmatician.");
   outtextxy(330,185,"He is considered to be father of graph theory.");
   outtextxy(330,210,"He solved the very famous Koingsberg bridge ");
   outtextxy(330,235,"problem in 1736 in his very first paper of GT.");

   /* draw ellipse */
   line(240,260,480,260);
   ellipse(300, 300, 0, 360, 40, 15);
   ellipse(430,300,0,360,40,15);
   line(340,300,390,300);
   line(342,302,390,302);
   line(240,340,480,340);
   line(430,285,430,260);
   line(432,285,432,260);
   line(430,315,430,340);
   line(432,315,432,340);
   line(280,260,295,285);
   line(282,260,297,285);
   line(320,260,305,285);
   line(318,260,303,285);
   line(280,340,295,315);
   line(282,340,297,315);
   line(320,340,305,315);
   line(318,340,303,315);
   outtextxy(300,298,"A");
   outtextxy(430,298,"B");
   getch();//delay(2500);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(4, HORIZ_DIR, 4);
   outtextxy(290,95,"WHAT IS EULAR GRAPH??");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(363,145,"In a graph G,if a closed walk contains ") ;
   outtextxy(310,170,"all the edges of the grapg G,the walk is ");
   outtextxy(280,195,"called a EULER LINE or EULER CYCLE.");
   outtextxy(340,225,"A graph G is called as EULER GRAPH if it");
   outtextxy(240,250,"contains a EULER LINE in G.");
   outtextxy(325,290,"An open walk in a graph is called an EULER");
   outtextxy(325,315,"PATH if it contains all the edges of graph G.");
   getch();//delay(2500);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(4, HORIZ_DIR, 4);
   outtextxy(315,100,"SIR WILLIAM HAMILTON");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(370,145,"Sir Rowan Hamilton was a very famous  ");
   outtextxy(332,170,"Irish mathematician. He invented a game ");
   outtextxy(330,195,"consisting of a solid regular dodecahedron ");
   outtextxy(340,220,"in 1857 and the concept is used in solving ");
   outtextxy(317,245,"the famous travelling salesman problem");
   outtextxy(337,270,"where the salesman is to eake a tour of all");
   outtextxy(340,295,"cities going through edges such that no city");
   outtextxy(300,320,"appears more than one in the tour. ");
   getch();//delay(2500);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(4, HORIZ_DIR, 3);
   outtextxy(290,95,"WHAT IS HAMILTONIAN GRAPH?");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(363,145,"In a graph G,a circuit that contains") ;
   outtextxy(310,170,"each vertex of G exactly once except the");
   outtextxy(325,195,"terminal vertices that appear twice is called");
   outtextxy(280,225,"as HAMILTONIAN CIRCUIT");
   outtextxy(320,250,"A graph G is called as HAMILTONIAN GRAPH");
   outtextxy(315,275,"if it contains a HAMILTONIAN CIRCUIT in G.");
   outtextxy(323,300,"If we delete one edge from the hamiltonian");
   outtextxy(327,325,"circuit,we get a path called HAMILTONIAN PATH");
   getch();//delay(2500);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(4, HORIZ_DIR, 4);
   outtextxy(310,95,"LET US TAKE A EXAMPLE...");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(330,140,"Suppose you wish to know presence of EULER");
   outtextxy(330,165,"or HAMILTONIAN path in following set of edges.");
   outtextxy(325,205,"{ a-b, a-c, b-e, b-c, c-e, e-d, c-d }");
   outtextxy(190,250,"Let us consider the ");
   outtextxy(170,275,"edges undirected.");
   outtextxy(175,305,"Then graph is =>");
   line(370,350,450,350);  //  e-d
   line(370,290,450,290); //  b-c
   line(370,350,370,290);  //  b-e
   line(450,350,450,290); //   c-d
   line(370,350,450,290);//e-c
   line(410,250,370,290);  //   a-b
   line(410,250,450,290);  //    a-c
   settextstyle(2, HORIZ_DIR, 7);
   outtextxy(410,240,"a");
   outtextxy(365,350,"e");
   outtextxy(365,290,"b");
   outtextxy(455,290,"c");
   outtextxy(455,350,"d");
   getch();//delay(2500);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(1, HORIZ_DIR, 3);
   outtextxy(310,95,"The graph has both EULER as well");
   outtextxy(310,125," as HAMILTONIAN path");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(310,155,"Let us see for Euler first.... ")  ;
   settextstyle(2, HORIZ_DIR, 7);
   outtextxy(300,205,"a");
   outtextxy(245,350,"e");
   outtextxy(245,260,"b");
   outtextxy(355,260,"c");
   outtextxy(355,350,"d");
   delay(500);
   line(250,260,350,260); //  b-c
   delay(500);
   line(300,210,350,260);  //    a-c
   delay(500);
   line(300,210,250,260);  //   a-b
   delay(500);
   line(250,350,250,260);  //  b-e
   delay(500);
   line(250,350,350,350);  //  e-d
   delay(500);
   line(350,350,350,260); //   c-d
   delay(500);
   line(250,350,350,260);//e-c
   delay(1000);

   clrscr();
   setfillstyle(10, maxcol);
   /* fill the screen with the pattern */
   bar(0, 0,maxx, midy/4-5);
   bar(0, 0,midx/4-15, maxy);
   bar(0, 7*midy/4-25,maxx, maxy);
   bar(7*midx/4+15, 0,maxx, maxy);
   setfillstyle(0, maxcol);
   bar(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   rectangle(midx/4-10,midy/4,7*midx/4+10,7*midy/4-30)  ;
   rectangle(midx/4-15,midy/4-5,7*midx/4+15,7*midy/4-25)  ;
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   settextstyle(1, HORIZ_DIR, 3);
   outtextxy(310,95,"The graph has both EULER as well");
   outtextxy(310,125," as HAMILTONIAN path");
   settextstyle(1, HORIZ_DIR, 2);
   outtextxy(310,155,"Now for Hamiltonian path.... ")  ;
   settextstyle(2, HORIZ_DIR, 7);
   outtextxy(300,205,"a");
   outtextxy(245,350,"e");
   outtextxy(245,260,"b");
   outtextxy(355,260,"c");
   outtextxy(355,350,"d");
   delay(1000);
   line(300,210,250,260);  //   a-b
   delay(500);
   line(250,350,250,260);  //  b-e
   delay(500);
   line(250,350,350,350);  //  e-d
   delay(500);
   line(350,350,350,260); //   c-d
   delay(500);
  }
}
Exemplo n.º 11
0
int utox_draw_text_multiline_within_box(int x, int y, /* x, y of the top left corner of the box */
                                        int right, int top, int bottom,
                                        uint16_t lineheight,
                                        const char_t *data, uint16_t length, /* text, and length of the text*/
                                        uint16_t h, uint16_t hlen,
                                        uint16_t mark, uint16_t marklen,
                                        _Bool multiline )
{
    uint32_t c1, c2;
    _Bool greentext = 0, link = 0, draw = y + lineheight >= top;
    int xc = x;
    char_t *a = data, *b = a, *end = a + length;
    while(1) {
        if(a != end) {
            if(*a == '>' && (a == data || *(a - 1) == '\n'))  {
                c1 = setcolor(COLOR_MAIN_QUOTETEXT);
                greentext = 1;
            }

            if((a == data || *(a - 1) == '\n' || *(a - 1) == ' ') && ((end - a >= 7 && memcmp(a, "http://", 7) == 0) || (end - a >= 8 && memcmp(a, "https://", 8) == 0))) {
                c2 = setcolor(COLOR_MAIN_URLTEXT);
                link = 1;
            }

            if(a == data || *(a - 1) == '\n') {
                char_t *r = a;
                while (r != end && *r != '\n') {
                    r++;
                }
                if (*(r - 1) == '<') {
                    if (greentext) {
                        setcolor(COLOR_MAIN_REDTEXT);
                    } else {
                        greentext = 1;
                        c1 = setcolor(COLOR_MAIN_REDTEXT);
                    }
                }
            }
        }

        if(a == end || *a == ' ' || *a == '\n') {
            int count = a - b, w = textwidth(b, count);
            while(x + w > right) {
                if(multiline && x == xc) {
                    int fit = textfit(b, count, right - x);
                    if(draw) {
                        drawtexth(x, y, b, fit, b - data, h, hlen, lineheight);
                        drawtextmark(x, y, b, fit, b - data, mark, marklen, lineheight);
                    }
                    count -= fit;
                    b += fit;
                    y += lineheight;
                    draw = (y + lineheight >= top && y < bottom);
                } else if(!multiline) {
                    int fit = textfit(b, count, right - x);
                    if(draw) {
                        drawtexth(x, y, b, fit, b - data, h, hlen, lineheight);
                        drawtextmark(x, y, b, fit, b - data, mark, marklen, lineheight);
                    }
                    return y + lineheight;
                } else {
                    y += lineheight;
                    draw = (y + lineheight >= top && y < bottom);
                    int l = utf8_len(b);
                    count -= l;
                    b += l;
                }
                x = xc;
                w = textwidth(b, count);
            }

            if(draw) {
                drawtexth(x, y, b, count, b - data, h, hlen, lineheight);
                drawtextmark(x, y, b, count, b - data, mark, marklen, lineheight);
            }

            x += w;
            b = a;

            if(link) {
                setcolor(c2);
                link = 0;
            }

            if(a == end) {
                if(greentext) {
                    setcolor(c1);
                    greentext = 0;
                }
                break;
            }

            if(*a == '\n') {
                if(greentext) {
                    setcolor(c1);
                    greentext = 0;
                }
                y += lineheight;
                draw = (y + lineheight >= top && y < bottom);
                b += utf8_len(b);
                x = xc;
            }

        }
        a += utf8_len(a);
    }

    return y + lineheight;
}
Exemplo n.º 12
0
Arquivo: 183.C Projeto: bearjb/studyc
main()
{
	int mode=VGAHI,driver=VGA;
	char ch;
 	unsigned int l;
 	int i,gi,gj,j,flag=1;/*i,j是循环变量,flag是标记变量,-1:向x负半轴移动,+1:向x正半轴移动*/
 	double qx,qy,k,b=0.0,speech=0.4,x,y;
 	double r=2.0,bx=60.0,byy=270.0;
 	double pianx=100.0,piany=100.0,tx=20.0,ty=10.0,jx=2.0,jy=2.0;
 	int mx=0,my=0,mb,sum;/*sum纪录砖块的数目*/
 	FILE * p;
  	if((p = fopen("record.dat", "r")) == NULL)
    	{
    		p=fopen("record.dat","w");
    		fprintf(p,"0 0 0 0 0\n");
    		rewind(p);
     	}
     	fclose(p);

	initgraph(&driver,&mode,"C:\\tc");
	setbkcolor(BLUE);
 	Msinit();
 	Setmouse((int)(pianx+1+bx/2),(int)((tx+jx)*8+pianx-1-bx/2),(int)byy+piany,(int)byy+piany);

star:	cleardevice();/*程序重载的介入点*/
	setcolor(RED);
	outtextxy(30,20,"^_^ Welcome to Play Hitting Brick Game! ^_^");

	sum=0;
 	qx=100.0+pianx-10;qy=180.0+pianx-10;k=0.33;
 	setcolor(7);
 	rectangle((int)(pianx-2),(int)(piany-2),(int)((tx+jx)*8+2+pianx),302+piany);
 	setcolor(1);
 	rectangle((int)(pianx-1),(int)(piany-1),(int)((tx+jx)*8+1+pianx),301+piany);
 	/*读取盘面情况*/
 	p=fopen("record.dat", "r");
 	for(i=0;i<5;i++)
 		fscanf(p,"%x ",&zhuan[i]);
 	fclose(p);
 	/*画砖块*/
 	for(i=0;i<5;i++)
 	{
 		l=1;
  		for(j=0;j<16;j++)
  		{
  			if((zhuan[i]&l)==0)
   			{
   				Draw((int)((jx+tx)*((16*i+j)%8)+pianx+jx),(int)((jy+ty)*((int)((16*i+j)/8))+piany+jy),(int)tx,(int)ty);
    				sum+=1;
   			}
   			l=l*2;
  		}
 	}
	gotoxy(5,4);
	printf("Press any key to start game...Q key to quit...");
	ch=getch();
	if(ch=='q'||ch=='Q')
		quitgame();
	else
	{
		gotoxy(5,4);
		printf("                                              ");
	}

 	for(;;)
	{
		setfillstyle(1, 0);
  		bar(mx-bx/2,my,mx+bx/2,my+5);
  		Msread(&mx, &my, &mb);

  		Draw(mx-bx/2,my,bx,5);
  		setcolor(0);
		mycircle(qx,qy,r,0);
  		/*判断求是否反弹*/
  		if(qx-r<=pianx+1 || qx+r>=(tx+jx)*8+pianx-1)
  		{
  			flag=-flag;
  			k=-k;
  		}
  		if(qy-r<=piany+1)
  			k=-k;

  		for(gi=0;gi<5;gi++)
  		{
  			l=1;
  			for(gj=0;gj<16;gj++)
  			{
  				if((zhuan[gi]&l)==0)
    				{
    					j=(16*gi+gj)/8;
     					i=(16*gi+gj)%8;
     					x=(jx+tx)*i+jx+tx/2+pianx;
     					y=(jy+ty)*j+jy+ty/2+piany;
     					/*边判断1*/
     					if(qy>=y-ty/2 && qy<=y+ty/2 &&(pow(qx+r-x+tx/2,2)<1 || pow(qx-r-x-tx/2,2)<1))
      					{
      						flag=-flag;
      						k=-k;
       						zhuan[gi]=zhuan[gi]|l;
       						sum-=1;
       						if(sum==0)
       							wingame();
       						setfillstyle(1, 0);
       						bar((jx+tx)*i+pianx+jx,(jy+ty)*j+piany+jy,(jx+tx)*i+pianx+jx+tx,(jy+ty)*j+piany+jy+ty);
      					}
      					else
      					/*边判断2*/
     					if(qx>=x-tx/2 && qx<=x+tx/2 &&(pow(qy+r-y+ty/2,2)<1 || pow(qy-r-y-ty/2,2)<1))
      					{
      						k=-k;
       						zhuan[gi]=zhuan[gi]|l;
       						sum-=1;
       						if(sum==0)
       							wingame();
       						setfillstyle(1, 0);
       						bar((jx+tx)*i+pianx+jx,(jy+ty)*j+piany+jy,(jx+tx)*i+pianx+jx+tx,(jy+ty)*j+piany+jy+ty);
      					}
      					else
      					/*角判断*/
     					if(pow(qx-x+tx/2,2)+pow(qy-y+ty/2,2)<=r*r || pow(qx-x-tx/2,2)+pow(qy-y+ty/2,2)<=r*r || pow(qx-x+tx/2,2)+pow(qy-y-ty/2,2)<=r*r || pow(qx-x-tx/2,2)+pow(qy-y-ty/2,2)<=r*r)
      					{
      						flag=-flag;
       						zhuan[gi]=zhuan[gi]|l;
       						sum-=1;
       						if(sum==0)
       							wingame();
       						setfillstyle(1, 0);
       						bar((jx+tx)*i+pianx+jx,(jy+ty)*j+piany+jy,(jx+tx)*i+pianx+jx+tx,(jy+ty)*j+piany+jy+ty);
      					}
     				}
     				l=l*2;
     			}
     		}
  		/*棍棒的反弹*/
  		if(qx<=mx+bx/2 && qx>=mx-bx/2 && pow(qy+r-my,2)<1)
  		{
  			k=-(k/pow(k*k,0.5))*(0.3*bx/(pow(pow(qx-mx,2),0.5)+0.000001));
  		}
  		if((int)(qy+r)>my+0.5)
  		{
			gotoxy(5,5);
  			printf("You have lost the game!Press any key to restart...");
  			getch();
  			goto star;
  		}
  		b=qy-qx*k;
  		if(flag==1)
  			qx=qx+speech/pow(1.0+k*k,0.5);
  		if(flag==-1)
  			qx=qx-speech/pow(1.0+k*k,0.5);
  		qy=qx*k+b;/*计算球心坐标*/
  		setcolor(14);
		mycircle((int)qx,(int)qy,r,14);
  		delay(1);
  		if(mb==1)
  		{
			gotoxy(5,5);
  			printf("You have lost the game!Press any key to restart...");
  			getch();
  			goto star;
  		}
 	}
}
Exemplo n.º 13
0
void main()
{
  int  Gd = DETECT, Gm;
  int  Drv;
  char GrErr;

  /* Find out which driver the user wants */
  printf("Which driver would you like to use?\n");
  printf("  0) Svga16\n");
  printf("  1) Svga256\n");
  printf("  2) Svga32k\n");
  printf("  3) Svga64k\n");
  printf("  4) SvgaTC\n");
  printf("  5) SvgaS3\n");
  printf("  6) Tweak256\n");
  printf("  7) Tweak16\n");
  printf("\n> ");
  scanf("%d",&Drv);
  switch(Drv)
  {
    case 0: installuserdriver("Svga16",DetectVGA16);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga16_fdriver);  */
	    break;

    case 1: installuserdriver("Svga256",DetectVGA256);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga256_fdriver); */
	    break;

    case 2: installuserdriver("Svga32k",DetectVGA32k);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga32k_fdriver);  */
	    break;

    case 3: installuserdriver("Svga64k",DetectVGA64k);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga64k_fdriver);  */
	    break;

    case 4: installuserdriver("SvgaTC",DetectVGA24bit);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(SvgaTC_fdriver);  */
	    break;

    case 5: installuserdriver("SvgaS3",DetectVGAS3);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(SvgaS3_fdriver);  */
	    break;

    case 6: installuserdriver("Twk16",DetectTwk16);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Twk16_fdriver);  */
	    break;

    case 7: installuserdriver("Twk256",DetectTwk256);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Twk256_fdriver);  */
	    break;
  }
  initgraph(&Gd,&Gm,"");

  /* Test if mode was initialized successfully */
  GrErr = graphresult();
  if (GrErr != grOk) {
      printf("Graphics error: %s\n",grapherrormsg(GrErr));
      exit(1);
  }

  /* Draw an 'X' on the screen */
  setcolor(RealDrawColor(WhitePixel()));
  line(0,0,getmaxx(),getmaxy());
  line(0,getmaxy(),getmaxx(),0);
  getch();
  closegraph();
}
Exemplo n.º 14
0
int main(int argc, char **argv) {
  int i, j, k, l;
  printf("color = 3, prob = 5 between 3 and 0\n");
  if(setcolor(gettid(), 3)) fprintf(stderr, "holy crap\n");
  if(setprob(3,0,5)) fprintf(stderr, "more crap\n");
  struct sched_param param;
  param.sched_priority = 0; 
  
  if(sched_setscheduler(0,4, &param) < 0) fprintf(stderr, "even more crap\n");
  
  /* fork(); */

  sched_yield();
  int b = 300;
  for(i = 0; i < b; i++) {
    if(i%49 == 0) {
      printf("i is divisible by 50\n");
    }
    for(j = 0; j < b; j++) {
      for(k = 0; k < b; k++) {
	l = j + k;
      }
    }
  }
	  

  

  
  /* pthread_t t1, t2, t3; */

  /* printf("%s\n", "testing setprob"); */
  /* if(setprob(-1,0,5)) { */
  /*   printf("%s %s\n", "invalid color1 lower bound: ", strerror(errno)); */
  /* } */
  /* if(setprob(5,0,5)) { */
  /*   printf("%s %s\n", "invalid color1 upper bound: ", strerror(errno)); */
  /* } */
  /* if(setprob(0,-1,5)) { */
  /*   printf("%s %s\n", "invalid color2 lower bound: ", strerror(errno)); */
  /* } */
  /* if(setprob(0,5,5)) { */
  /*   printf("%s %s\n", "invalid color2 upper bound: ", strerror(errno)); */
  /* } */
  /* if(setprob(0,0,11)) { */
  /*   printf("%s %s\n", "invalid prob upper bound: ", strerror(errno)); */
  /* } */
  /* if(setprob(0,0,-1)) { */
  /*   printf("%s %s\n", "invalid prob lower bound: ", strerror(errno)); */
  /* } */
  /* printf("\n"); */
  
  /* printf("%s\n", "testing getprob after bad values"); */
  /* printf("%s %ld\n", "getprob(0,0))", getprob(0,0)); */

  /* printf("\n"); */

  /* printf("%s\n", "setting the following color probabilities"); */
  /* printf("%s\n", "setprob(0,1,1))"); */
  /* if(setprob(0,1,1)) { */
  /*   printf("%s\n", strerror(errno)); */
  /* } */
  /* else { */
  /*   printf("success!\n"); */
  /* } */
  /* printf("%s\n", "setprob(0,0,3)"); */
  /* if(setprob(0,0,3)) { */
  /*   printf("%s\n", strerror(errno)); */
  /* } */
  /* else { */
  /*   printf("success!\n"); */
  /* } */
  /* printf("\n"); */

  /* printf("%s\n", "testing getprob.  check the returns!"); */
  /* printf("%s: %ld\n", "getprob(0,0)", getprob(0,0)); */
  /* printf("%s: %ld\n", "getprob(0,1)", getprob(0,1)); */

  /* printf("\n"); */
  /* printf("%s\n", "testing setcolor with invalid pid"); */
  /* if(setcolor(-1, 4)) { */
  /*   printf("%s %s\n", "invalid pid", strerror(errno)); */
  /* } */
  /* printf("%s\n", "testing setcolor(gettid(), 4) with current pid"); */
  /* if(setcolor(gettid(), 4)) { */
  /*   printf("%s\n", "this should not have failed"); */
  /* } */
  /* else { */
  /*   printf("success!\n"); */
  /* } */

  /* printf("%s\n", "testing getcolor(gettid())"); */
  /* if(getcolor(gettid()) != 4) { */
  /*   printf("%s: %s\n", "problem", strerror(errno)); */
  /* } */
  /* else { */
  /*   printf("success!\n"); */
  /* } */
    
  return 0;
}
Exemplo n.º 15
0
void Ventilation (void)
   {
   register int       flagvvm = 0;
   register int        ncol, nlin,
		       escala, y0,
			   y1, y2;
   int             y_ini0, y_ini1;
   int                        cor;

   float    far              *apt;
   float    far           *aptaux;
   register float  flux, sum_flux;
   float                   sum[4];
#ifdef    BYPASS_VVM
   int                   step = 0;
   int                 offset = 0;
#endif    BYPASS_VVM

   LeData ();

   getviewsettings (&vp);

   VentVolMax = sum_flux    = 0.0;
   NumeroSinal      =           0;
   escala           = DELTA_Y(14);
   coluna           = DELTA_X( 6);
   y0 = y_ini0      = DELTA_Y(74);
   y2 = y1 = y_ini1 = DELTA_Y(90);

   apt              =    inicVVM1;
   aptaux           = inicVVM1Int;
   Atendeu          =       FALSE;
   sum[0] = sum[1]  =
   sum[2] = sum[3]  =         0.0;
   LinBaseVVM1 = LinBaseVVM2 =0.0;

#ifndef    BYPASS_HADWARE
#ifndef    BYPASS_VVM
   IniAquisition();
   EnableInt();
#endif     BYPASS_VVM
#endif     BYPASS_HADWARE

   do {
#ifndef    BYPASS_VVM
      DisableInt();
#endif     BYPASS_VVM
      Help = kbhit() && (ESC == getch());
#ifndef    BYPASS_VVM
      EnableInt();
#endif     BYPASS_VVM
      if (Help)	 Abortou = TRUE;
      else
	 {
#ifndef    BYPASS_VVM
	 while(!Atendeu);
	 Sinal -= (int)Zero;
#else      BYPASS_VVM
	 Sinal  = 14;
#endif     BYPASS_VVM
	 Atendeu = FALSE;
	 }
      } while( (abs(Sinal) < 10) && (!Abortou) );

   if (!Abortou)
      {
#ifdef  GRAVACAO_DE_DADOS
      fprintf ( PDados, "\n\n\t %%%%%%%%%%% VENTVOL: %%%%%%%%%%%");
#endif  GRAVACAO_DE_DADOS
      do {
#ifndef    BYPASS_VVM
	 DisableInt();
#endif     BYPASS_VVM
	 Help = kbhit() && (ESC == getch());
#ifndef    BYPASS_VVM
	 EnableInt();
#endif     BYPASS_VVM
	 if (Help)  Abortou = TRUE;
	 else
	     {
#ifndef    BYPASS_VVM
	     while(!Atendeu);

	     *aptaux = flux = (Sinal > Zero)  ?
				 VDxFluxo ( Sinal , GanhoExp ):
				 VDxFluxo ( Sinal , GanhoIns );

#else      BYPASS_VVM
	     /* ----------------------------- */
	     /* Simulacao de um Alcaponamento */
	     /* ----------------------------- */
	     if (!(NumeroSinal % 15))
		{
		offset = -1;
		}
	     else
		{
		offset =  0;
		}

	     if ( NumeroSinal > 1200 )
		{
		offset = -2;
		}
	     if ( NumeroSinal > 1300 )
		{
		offset =  0;
		}

	     *aptaux = flux = 10 * cos ( (M_PI * step++) /60) + offset;
#endif     BYPASS_VVM

#ifdef     GRAVACAO_DE_DADOS
	     fprintf ( PDados, "\n\t%04X", Sinal);
#endif     GRAVACAO_DE_DADOS


	     if (*aptaux > 0.0)
	       {
	       VentVolMax += flux / SampleRatio;
	       flagvvm = 1;
	       }

#ifdef VVM_ALCAP_
	     sum_flux += flux / SampleRatio;

	     sum[0] = (.01 * sum_flux) + (.19 * sum[1]) +
		      (.30 *   sum[2]) + (.50 * sum[3]);

	     sum[3] = sum[2];
	     sum[2] = sum[1];
	     sum[1] = sum[0];

	     /* --------------------------- */
	     /* Calculo das Linhas de Base  */
	     /* para obtencao do valor do   */
	     /* volume Alcaponado.          */
	     /*                             */
	     /* Convecionou-se:             */
	     /* LBASE1 -> Volume Medio Entre*/
	     /*           2 e 3 segundos.   */
	     /*                             */
	     /* LBASE2 -> Volume Medio Entre*/
	     /*           10 e 11 segundos. */
	     /*                             */
	     /* Volume Acapondado Extrapola-*/
	     /* do a um minuto sera a dife- */
	     /* das das linhas de Base vezes*/
	     /* 7.5 (que e'60/8)            */
	     /* --------------------------- */

	     if      ( (NumeroSinal >=  200) && (NumeroSinal <  400) )
		/* ------- */
		/* LBASE_1 */
		/* ------- */
		{
		LinBaseVVM1 += sum[0];

		}
	     else if ( (NumeroSinal >= 2000) && (NumeroSinal < 2200) )
		/* ------- */
		/* LBASE_2 */
		/* ------- */
		{
		LinBaseVVM2 += sum[0];
		}
#else  VVM_ALCAP_
	     sum_flux = sum_flux;
	     y_ini1 = y_ini1;
	     y0 = y0;
	     y1 = y1;
	     y2 = y2;
#endif  VVM_ALCAP_

	     if (flagvvm)
	     {
	     *apt = VentVolMax;

	     /* --------------------------- */
	     /* Um ponto chega a cada 5ms   */
	     /* Totalizando 2400 ptos em 12s*/
	     /* Os 12s medem DELTA_X(88),   */
	     /* logo a coluna atual depende */
	     /* de NumSinal segundo a formu-*/
	     /* la abaixo:                  */
	     /* --------------------------- */
	     ncol = (int) ( (((long) NumeroSinal) * DELTA_X(88))/2400  +
			    DELTA_X( 6) );

	     if ( ncol != coluna )
		{
		cor = getcolor();

		/* -------------------------- */
		/* Tracado do Volume Expirado */
		/* -------------------------- */
		nlin = (int) ((y_ini0 - (((long) escala ) * VentVolMax)/10));

		moveto(coluna, y0);
		lineto( coluna, nlin );
		y0 = nlin;

#ifdef VVM_ALCAP_
		setcolor (bea_color[ 7]);

		/* ----------------------------- */
		/* Tracado do Volume (Invertido) */
		/* ----------------------------- */
		nlin = (int) ((y_ini1 + (((long) escala ) * (sum_flux))/2));

		moveto(coluna, y1);
		lineto( coluna, nlin );
		y1 = nlin;

		setcolor (bea_color[11]);

		/* -------------------------------------------------- */
		/* Tracado Valor Medio Filtrado do Volume (Invertido) */
		/* -------------------------------------------------- */
		nlin = (int) ((y_ini1 + (((long) escala ) * (sum[0]))/2));
		moveto(coluna, y2);
		lineto( coluna, nlin );
		y2 = nlin;
#endif VVM_ALCAP_

		setcolor (cor);

		coluna = ncol;
		}

	     ++NumeroSinal;
	     }

	     ++apt;
	     ++aptaux;

	     Atendeu = FALSE;
	     }
	 } while ( (NumeroSinal != NUMMAXPONTOSINF-1) &&
		   (coluna != DELTA_X(88) + DELTA_X( 6)) &&
		   (!Abortou) );



#ifndef    BYPASS_VVM
      DisableInt();
#endif     BYPASS_VVM

      for (; apt<inicVVM1+NUMMAXPONTOSINF; apt++)
	  {
	  *apt = FIM_1;
	  }

      *aptaux = END;
      *(aptaux+1) = TempAmb;
      *(aptaux+2) = UmidRel;
      *(aptaux+3) = PresBar;

      if (!Abortou)
	 {
	 if (FlagIntegridade) ReCalcula();

	 CalculaParamVVM();
	 CalculaVVMpercent();

	 outtextxy(DELTA_X(25) , DELTA_Y( 5),
		   "Param Teorico Calculado  %");
	 cor = getcolor();
	 setcolor(bea_color[15]);
	 gprintf  (DELTA_X(25) , DELTA_Y( 6) + CharH,
		   "VVM   %6.2f  %6.2f   %4.0f",
		   VentVolMaxteorico,
		   VentVolMax,
		   (VentVolMaxpercent+0.5));

#ifdef VVM_ALCAP_
	 gprintf  (DELTA_X(25) , DELTA_Y( 7) + 2 * CharH,
		   "ALCAP    --  %7.2f     - ",
		   VolAlcaponado);
#endif VVM_ALCAP_


	 setcolor(cor);

	 if (teste1VVM)
	    {
	    teste2VVM = TRUE;
	    teste1VVM = FALSE;
	    }
	 else
	    teste1VVM = TRUE;
	 }
      }
#ifndef    BYPASS_VVM
   else  DisableInt();
#endif     BYPASS_VVM
   }        /* Ventilation */
Exemplo n.º 16
0
void main()
{
int gd=DETECT,gm,x,y,x1,y1,ff,yy,flag=0,flag2=0,ch;
initgraph(&gd,&gm,"");
x1=getmaxx();
y1=getmaxy();
x=630/2;
y=6;
x1=2;
setcolor(WHITE);
setbkcolor(BLACK);

    while(1)
    {
	setcolor(YELLOW);
	rectangle(2,2,638,478);
	setcolor(WHITE);
	settextstyle(4,0,2);
	settextjustify(CENTER_TEXT,CENTER_TEXT);
	outtextxy(getmaxx()/2,getmaxy()/2,"Designed by : Soumen mukherjee");
	setcolor(WHITE);
	circle(x,y,5);
		circle(x,y,4);
		setcolor(LIGHTRED);
		  circle(x,y,3);
		   circle(x,y,2);
		     delay(25);
	    setcolor(BLACK);
    circle(x,y,5);
	circle(x,y,4);
	  circle(x,y,3);
	    circle(x,y,2);


	if((y<476 && flag==0) || y<0 )
    y+=x1;
    if(y==476 || y>476)
    {
    flag=1;
    sound(4500);
    delay(5);
    nosound();
    }
    if((y>6 && flag==1) || y>476)
    y-=x1;
    if(y==6 || y<6)
    {
    flag=0;
    sound(4500);
    delay(5);
    nosound();
    }
    if(flag2==1)
    {
    x+=x1;
    if(x>630)
    {
    x=629;
    flag2=2;
    sound(4500);
    delay(5);
    nosound();
    }

    }
    if(flag2==2)
    {
    x-=x1;
    if(x<5)
    {
    x=6;
    flag2=1;
    sound(4500);
    delay(5);
    nosound();
    }
    }
    if(kbhit())
    {
    ch=getch();
    if(ch==13)
    break;
    if(ch==77)
    {
    x+=5;
    if(x>630)
    x=629;
    flag2=1;
    }
    if(ch==75)
    {
    x-=5;
    if(x==5)
    x=6;
    flag2=2;
     }
    if(ch==72)
    {
    x1+=2;
    if(x1==60)
    x1=58;
    }
    if(ch==80)
    {
    x1-=2;
    if(x1==0)
    x1=2;
    }
    }
	}
     closegraph();
	 restorecrtmode();
    }
Exemplo n.º 17
0
void GraficoVVMSecund (void)
   {
   register int     i, ncol, nlin,
		       escala, y0,
			   y1, y2;
   int             y_ini0, y_ini1;
   int                        cor;

   float    far              *apt;
   float    far           *aptaux;
   register float  flux, sum_flux;
   float                   sum[4];


   inicVVM2    =    inicVVM1;
   inicVVM2Int = inicVVM1Int;



   AtivaJanelaGrafica(GRAF2,0);
   setcolor ( bea_color[14] );

   clearviewport();

   getviewsettings (&vp);


   DesenhaEixos( DELTA_X( 5), DELTA_X(97),
		 DELTA_Y( 4), DELTA_Y(80),
		 DELTA_X( 4), DELTA_Y(20),
		 DELTA_X(22), DELTA_Y(11) );


   sum_flux         =         0.0;
   escala           = DELTA_Y(11);
   coluna           = DELTA_X( 9);
   y0 = y_ini0      = DELTA_Y(60);
   y2 = y1 = y_ini1 = DELTA_Y(75);

   apt              =    inicVVM2;
   aptaux           = inicVVM2Int;
   sum[0] = sum[1]  =
   sum[2] = sum[3]  =         0.0;


   ScalaVVMSecund();


   for (   i = 0;
	   (*apt != FIM_1) &&
	   (apt < inicVVM2 + NUMMAXPONTOSINF);
	   apt++, i++    )
      {

      flux = *aptaux; aptaux++;
#ifdef VVM_ALCAP_
      sum_flux += flux / SampleRatio;

      sum[0] = (.01 * sum_flux) + (.19 * sum[1]) +
	       (.30 *   sum[2]) + (.50 * sum[3]);

      sum[3] = sum[2];
      sum[2] = sum[1];
      sum[1] = sum[0];
#else  VVM_ALCAP_
      sum_flux = sum_flux;
      flux = flux;
      y_ini1 = y_ini1;
      y0 = y0;
      y1 = y1;
      y2 = y2;
#endif  VVM_ALCAP_

      ncol = (int) ( (((long) i) * DELTA_X(88))/2400 + DELTA_X( 9) );

      if ( ncol != coluna )
	 {
	 cor = getcolor();

	 /* -------------------------- */
	 /* Tracado do Volume Expirado */
	 /* -------------------------- */
	 nlin = (int) ((y_ini0 - (((long) escala ) * (*apt))/10));

	 moveto(coluna, y0);
	 lineto( coluna, nlin );
	 y0 = nlin;

#ifdef VVM_ALCAP_
	 setcolor (bea_color[ 7]);

	 /* ----------------------------- */
	 /* Tracado do Volume (Invertido) */
	 /* ----------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum_flux))/2));

	 moveto(coluna, y1);
	 lineto( coluna, nlin );
	 y1 = nlin;

	 setcolor (bea_color[11]);

	 /* -------------------------------------------------- */
	 /* Tracado Valor Medio filtrado do Volume (Invertido) */
	 /* -------------------------------------------------- */
	 nlin = (int) ((y_ini1 + (((long) escala ) * (sum[0]))/2));
	 moveto(coluna, y2);
	 lineto( coluna, nlin );
	 y2 = nlin;
#endif VVM_ALCAP_

	 setcolor (cor);

	 coluna = ncol;
	 }

      }

   VentVolMax2 = VentVolMax;

   VentVolMaxpercen2 = VentVolMaxpercent;

   VolAlcaponado2 = VolAlcaponado;

   outtextxy( DELTA_X ( 5),
	      DELTA_Y (85),
	      "Param  Teor    Calc      %");

   cor = getcolor ();

   setcolor (bea_color[15]);

   gprintf( DELTA_X ( 5),
	    DELTA_Y (87) + CharH,
	    "VVM    %6.2f  %6.2f  %4.0f",
	    VentVolMaxteorico,
	    VentVolMax2,
	    (VentVolMaxpercen2 + 0.5));

#ifdef VVM_ALCAP_
   gprintf  (DELTA_X( 5),
	     DELTA_Y(89) + 2 * CharH,
	     "ALCAP    --   %7.2f    - ",
	     VolAlcaponado2);
#endif VVM_ALCAP_


   setcolor (cor);

   DesativaJanelaGrafica(GRAF2);

   }  /* GraficoVVMSecund */
Exemplo n.º 18
0
 void drawball()
 {
     setfillcolor(color);
     setcolor(color);
     fillellipse((int)x, (int)y, (int)r, (int)r);
 }
Exemplo n.º 19
0
void VentVol ( void )
   {
   int opcao1, opcao2;

   float far *apt1;
   float far *apt2;
   float   far *apt3;
   float   far *apt4;


   inicVVM1    = ApontVVM;
   inicVVM1Int = ApontVVMInt;
   menuVVM[0]  = "EXECUTAR TESTE";
   menuVVM[1]  = "   RETORNAR   ";

   AmbienteVentVolMax();

   getviewsettings(&vp);
   if (*inicVVM1 != NULL)
      {
      teste1VVM = TRUE ;
      GraficoVVMSecund();
      grafSecundVVM = TRUE;
      }
   else
      {
      ManobVVMAtiva = 1;
      NumManobVVM = 0;
      teste1VVM = grafSecundVVM = FALSE;
      }

   teste2VVM = FALSE;
   do {
      Abortou = FALSE;
      LimpaBufferTeclado();

      opcao1 = MenuVentVolMax();

      if (opcao1 == EXECUTAR)
	 {
	 DesativaJanelaGrafica(MENU_3);

	 if ((teste1VVM)&&(!grafSecundVVM))
	     {
	     GraficoVVMSecund();
	     grafSecundVVM = TRUE;
	     }
	 else if (teste2VVM)
	     {
	     MelhorProvaVVM (ManobVVMAtiva, NumManobVVM);
	     teste2VVM = FALSE;
	     teste1VVM = TRUE ;
#ifdef  MODO_VGA_640X480_HIG
	     AmbienteVentVolMax();
#endif  MODO_VGA_640X480_HIG
	     GraficoVVMSecund();
	     }

	 AtivaJanelaGrafica(GRAF1,0);
	 setcolor ( bea_color[14] );

	 clearviewport();

	 ProcuraZero();

	 if (ZeroOk)
	    {
	    inicVVM2 = inicVVM1;
	    inicVVM1 = (inicVVM1 == areaTampao) ? areaVVM : areaTampao;
	    inicVVM2Int = inicVVM1Int;
	    inicVVM1Int = (inicVVM1Int == areaTampaoInt) ? areaVVMInt : areaTampaoInt;

	    clearviewport();
	    getviewsettings(&vp);

	    DesenhaEixos( DELTA_X( 4), DELTA_X(96),
			  DELTA_Y( 4), DELTA_Y(98),
			  DELTA_X( 2), DELTA_Y(24),
			  DELTA_X(22), DELTA_Y(14) );

	    ScalaVVM();

	    DesativaJanelaGrafica(GRAF1);
	    AtivaJanelaGrafica(MENU_3, 0);
	    setcolor ( bea_color[14] );
	    menuVVM[0] = "   INICIAR    ";
	    menuVVM[1] = "   ANULAR     ";

	    do {
	       ++NumManobVVM;
	       testVVMOk = FALSE;
	       LimpaBufferTeclado();
	       opcao2 = MenuVentVolMax();
	       if (opcao2 == INICIAR)
		  {
		  DesativaJanelaGrafica(MENU_3);
		  AtivaJanelaGrafica(GRAF1, 0);
		  setcolor ( bea_color[14] );

		  /* --------------- */
		  /* Executa Manobra */
		  /* --------------- */
		  Ventilation();

		  testVVMOk = TRUE;
		  DesativaJanelaGrafica(GRAF1);
		  }
	       } while((opcao2 != ANULAR)&&(!testVVMOk));

	    if ((opcao2 == ANULAR)||(Abortou))
	       {
	       --NumManobVVM;
	       inicVVM1  = inicVVM2;
	       inicVVM2 = NULL ;
	       inicVVM1Int  = inicVVM2Int;
	       inicVVM2Int = NULL ;
	       }

	    ApontVVM = inicVVM1;
	    ApontVVMInt = inicVVM1Int;
	    AtivaJanelaGrafica(MENU_3,0);
	    setcolor ( bea_color[14] );

	    menuVVM[0] = "EXECUTAR TESTE";
	    menuVVM[1] = "   RETORNAR   ";

	    }
	 else  DesativaJanelaGrafica(GRAF1);
	 }

      } while(opcao1 != RETORNAR);

   setcolor(bea_color[14]);

   if (teste2VVM)    MelhorProvaVVM (ManobVVMAtiva, NumManobVVM);
   if (inicVVM1 == areaTampao)
      {
      for ( apt1   = areaTampao,apt2=areaVVM;
	    apt1  != areaTampao+NUMMAXPONTOSINF;
	    apt1++, apt2++  )
	     {
	     *apt2 = *apt1;
	     }

      ApontVVM = areaVVM;

      for ( apt3   = areaTampaoInt,apt4 = areaVVMInt;
	    apt3  != areaTampaoInt + NUMMAXPONTOSINF;
	    apt3++, apt4++)
	     {
	     *apt4 = *apt3;
	     }
      ApontVVMInt  = areaVVMInt;
      }
   else
      {
      ApontVVM     =    inicVVM1;
      ApontVVMInt  = inicVVM1Int;
      }

   inicVVM1    = NULL;
   inicVVM2    = NULL;
   inicVVM1Int = NULL;
   inicVVM2Int = NULL;

   } /* VentVol */
Exemplo n.º 20
0
// function definition to create trunk of the mill
void drawMillStand(int x,int y)
{
    setcolor(LCYAN);   // setting a color for the co-ordinate axes
    line(fx(x),fy(y),fx(x),Y);   // drawing the stand
} // end of function
Exemplo n.º 21
0
void main(void)
{
	int key,
		v,
		h;
	int oldv=0,oldh=0;
	int x1,y1,x2,y2;
	int x;

	turnon();
	graphics_setup();
	setcolor(c7);

	initrat(&rat);
	key = checkinput();
	h=rat.horiz;
	v=rat.verti;
	oldh=h;
	oldv=v;
	r1=0.0;
	r2=0.0;
	r3=0.0;
	msz=-150;
	newpos();
	while(!(key==ESC))
	{
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;
		if(oldh!=h)
		{
			if(oldh<h)
			{
				if(r1+0.1>6.28319)
					r1=0.0;
				else
					r1+=0.1;
			}
			else
			{
				if(r1-0.1<0.0)
					r1=6.28319;
				else
					r1-=0.1;
			}
			newpos();
		}
		if(oldv!=v)
		{
			if(oldv>v)
			{
				if(r3+0.1>6.28319)
					r3=0.0;
				else
					r3+=0.1;
			}
			else
			{
				if(r3-0.1<0.0)
					r3=6.28319;
				else
					r3-=0.1;
			}
			newpos();
		}
		resetrat(&rat);
		h=rat.horiz;
		v=rat.verti;
		oldh=h;
		oldv=v;
		switch(key)
		{
			case UP:	msz+=10;
						newpos();
						break;
			case DOWN:	msz-=10;
						newpos();
						break;
			case LEFT:	if(r2+0.1>6.28319)
							r2=0.0;
						else
							r2+=0.1;
						newpos();
						break;
			case RIGHT:	if(r2-0.1<0.0)
							r2=6.28319;
						else
							r2-=0.1;
						newpos();
						break;
/*			case PGUP:	hand[0]=x;
						hand[1]=y-17;
						hand[2]=x;
						hand[3]=y+8;
						hand[4]=x-10;
						hand[5]=y-12;
						hand[6]=x;
						hand[7]=y;
						hand[8]=x+10;
						hand[9]=y-12;
						hand[10]=x;
						hand[11]=y;
						drawhand(h,v,oldh,oldv);
						break;
			case PGDN:	hand[0]=x;
						hand[1]=y-17;
						hand[2]=x;
						hand[3]=y+8;
						hand[4]=x-10;
						hand[5]=y-12;
						hand[6]=x;
						hand[7]=y;
						hand[8]=x+10;
						hand[9]=y-12;
						hand[10]=x;
						hand[11]=y;
						drawhand(h,v,oldh,oldv);
						break; */
		}
	}
	ratoff();
	turnoff();
	quit_pgm();
}
Exemplo n.º 22
0
 ~scope_setcolor()
 {
     if( m_os )
         *m_os << setcolor( m_is_color_output );
 }
Exemplo n.º 23
0
Arquivo: ui.c Projeto: notadecent/uTox
static void drawadd(int x, int y, int width, int height)
{
    setcolor(C_TITLE);
    setfont(FONT_SELF_NAME);
    drawstr(LIST_RIGHT + SCALE * 5, SCALE * 10, "Add Friends");
}
Exemplo n.º 24
0
static void
pixtoval(void)				/* convert picture to values */
{
	register COLOR	*scanln;
	int  dogamma;
	COLOR  lastc;
	RREAL  hv[2];
	int  startprim, endprim;
	long  startpos;
	int  y;
	register int  x;

	scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR));
	if (scanln == NULL) {
		fprintf(stderr, "%s: out of memory\n", progname);
		quit(1);
	}
	dogamma = gamcor < .95 || gamcor > 1.05;
	if (putprim == ALL && !interleave) {
		startprim = RED; endprim = BLU;
		startpos = ftell(fin);
	} else {
		startprim = putprim; endprim = putprim;
	}
	for (putprim = startprim; putprim <= endprim; putprim++) {
		if (putprim != startprim && fseek(fin, startpos, 0)) {
			fprintf(stderr, "%s: seek error on input file\n",
					progname);
			quit(1);
		}
		set_io();
		setcolor(lastc, 0.0, 0.0, 0.0);
		for (y = 0; y < numscans(&picres); y++) {
			if (freadscan(scanln, scanlen(&picres), fin) < 0) {
				fprintf(stderr, "%s: read error\n", progname);
				quit(1);
			}
			for (x = 0; x < scanlen(&picres); x++) {
				if (uniq) {
					if (	colval(scanln[x],RED) ==
							colval(lastc,RED) &&
						colval(scanln[x],GRN) ==
							colval(lastc,GRN) &&
						colval(scanln[x],BLU) ==
							colval(lastc,BLU)	)
						continue;
					else
						copycolor(lastc, scanln[x]);
				}
				if (doexposure)
					multcolor(scanln[x], exposure);
				if (dogamma)
					setcolor(scanln[x],
					pow(colval(scanln[x],RED), 1.0/gamcor),
					pow(colval(scanln[x],GRN), 1.0/gamcor),
					pow(colval(scanln[x],BLU), 1.0/gamcor));
				if (!dataonly) {
					pix2loc(hv, &picres, x, y);
					printf("%7d %7d ",
							(int)(hv[0]*picres.xr),
							(int)(hv[1]*picres.yr));
				}
				if ((*putval)(scanln[x]) < 0) {
					fprintf(stderr, "%s: write error\n",
							progname);
					quit(1);
				}
			}
		}
	}
	free((void *)scanln);
}
Exemplo n.º 25
0
int main(void)
{
   int gdriver, gmode;

   /* install a user written device driver */
   gdriver = installuserdriver("svga256", detectSVGA256);

   /* must force use of detection routine */
   gdriver = DETECT;

   /* check for any installation errors */
    /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "d:\\prog\\project\\");
   int y1=getmaxy();
   int x=getmaxx();

   struct palettetype pal;
float i, ht, y, xmax;
   getpalette(&pal);
   /* check for any initialization errors */
       /* draw a line */
    for (i=0; i<pal.size; i++)
   setrgbpalette(pal.colors[i], i*4, i*4, i*4);
   setcolor(9);
   line(0, 0, getmaxx(), getmaxy());
    ht = getmaxy() / 255;
xmax = getmaxx();
y = 0;
for (i=0; i<256; i++)
{
   static int t[]={0,0,0,50,50,50,50,0,};
   setfillstyle(SOLID_FILL, i);
   setcolor(0);
   fillpoly(4,t);
   char cnum[10];
   settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
   setcolor(0);
   itoa(i,cnum,10);
   outtextxy(t[0],t[1],cnum);
   for(int i=0;i<8;i+=2)
   t[i]+=50;
   //bar(0, y, xmax, y+ht);
   y += ht;
   if(t[4]>getmaxx())
   {for(int i=0;i<8;i+=2)
   t[i+1]+=50;
   for(i=0;i<4;i+=2)
   t[i]=0;
   for(i=4;i<8;i+=2)
   t[i]=50;}
//   getch();

}    setcolor(59);
   //line(0, 0, getmaxx(), getmaxy());
    //circle(0,0,500);
    printf("%i%i",x+1,y1+1);
    //printf(" hello %i",getpalettesize());
   /* clean up */
    getch();
   closegraph();
   return 0;
}
Exemplo n.º 26
0
void AmbienteVentVolMax (void)
{
   char   id;


   LimpaTela();

   setcolor ( bea_color[12] );

   CriaJanelaGrafica( MENU_3,
		      PER_X(62), PER_Y( 3),
		      PER_X(99), PER_Y(28),
		      0, "VENTILACAO VOLUNTARIA MAXIMA");

   CriaJanelaGrafica( DADOS,
		      PER_X( 1), PER_Y( 3),
		      PER_X(61), PER_Y(28),
		      0,"DADOS DO PACIENTE");

   CriaJanelaGrafica( GRAF1,
		      PER_X( 1), PER_Y(30),
		      PER_X(61), PER_Y(99),
		      0,"MANOBRA");

   CriaJanelaGrafica( GRAF2,
		      PER_X(62), PER_Y(30),
		      PER_X(99), PER_Y(99),
		      0,"MANOBRA ANTERIOR");

   AtivaJanelaGrafica(DADOS,0);
   setcolor ( bea_color[14] );

   getviewsettings(&vp);

   gprintf( DELTA_X( 2), DELTA_Y(15),
	    "NOME: %s",Paciente.Nome);

   id = Paciente.Prontuario[7];
   Paciente.Prontuario[7] = '\0';
   gprintf( DELTA_X( 2), DELTA_Y(35),
	    "No DO PRONTUARIO: %s %c",Paciente.Prontuario, id);
   Paciente.Prontuario[7] = id;

   gprintf( DELTA_X(70), DELTA_Y(35),
	    "SEXO: %s",Paciente.Sexo);

   gprintf( DELTA_X( 2), DELTA_Y(55),
	    "IDADE: %s",PacienteIdade);

   gprintf( DELTA_X(30), DELTA_Y(55),
	    "ALTURA(cm): %s",Paciente.Altura);

   gprintf( DELTA_X(70), DELTA_Y(55),
	    "PESO(Kg): %s",Paciente.Peso);

   gprintf( DELTA_X( 2), DELTA_Y(75),
	    "SUP.CORPOREA(m2): %3.2f",SupCorp);

   AtivaJanelaGrafica(MENU_3, 0);
   setcolor ( bea_color[14] );

   getviewsettings(&vp);

   outtextxy(  DELTA_X(50) - textwidth(menuVVM[0])/2, DELTA_Y(35),
	       menuVVM[0]);
   outtextxy(  DELTA_X(50) - textwidth(menuVVM[1])/2, DELTA_Y(60),
	       menuVVM[1]);

}  /* AmbienteVentVolMax */
Exemplo n.º 27
0
void hover_text(int n)
{	
if(cur_color==BLACK)
setcolor(WHITE);
else
setcolor(BLACK);
	switch(n)
	{
	case 1:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"New File");
			break;
	case 2:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Save File");
			break;
	case 3:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Load File");
			break;
	case 4:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Text");
			break;
	case 5:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Pencil");
			break;
	case 6:
			setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Eraser");
			break;
	case 7:	setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Fill Color");
			break;
	case 8:	setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Brush");
			break;
	case 9:	setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Pick Color");
			break;
	case 10:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Draw Line");
			break;
	case 11:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Rectangle");
			break;
	case 12:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Ellipse");
			break;
	case 13:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Spray");
			break;
	case 14:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Spiral");
			break;
	case 15:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Clipping");
			break;
	case 16:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Polygon");
			break;
	case 17:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Circle");
			break;
	case 18:setfillstyle(1,cur_color);
			bar(500,3,600,17);
			outtextxy(500,5,"Colors");
			break;
	}

}
Exemplo n.º 28
0
int MenuVentVolMax ( void )
   {
   int  Cont = 0,
	Lin[2],
	alt;

   Lin[0] = 35;
   Lin[1] = 60;

   AtivaJanelaGrafica(MENU_3,0);
   setcolor ( bea_color[14] );
   getviewsettings(&vp);

   alt = CharH;
   setviewport( vp.left , vp.top + DELTA_Y(Lin[Cont]) - 1,
		vp.right, vp.top + DELTA_Y(Lin[Cont]) + 1 + alt, 1);
   clearviewport();
   setfillstyle(1, bea_color[14]);
   floodfill(1,1,1);
   setcolor(bea_color[ 0]);
   outtextxy(  DELTA_X(50) - textwidth(menuVVM[Cont])/2, 2, menuVVM[Cont]);



   setviewport( vp.left , vp.top + DELTA_Y(Lin[1]) - 1,
		vp.right, vp.top + DELTA_Y(Lin[1]) + 1 + alt, 1);
   clearviewport();
   setfillstyle(1, bea_color[0]);
   floodfill(1,1,1);
   setcolor(bea_color[14]);
   outtextxy(  DELTA_X(50) - textwidth(menuVVM[1])/2, 2, menuVVM[1]);



   do {
      LimpaBufferTeclado();
      sc.c = LeTeclado();
      if (sc.ch[0] == 0)
	 if (sc.ch[1]==72 || sc.ch[1]==80)
	    {
	    setviewport( vp.left , vp.top + DELTA_Y(Lin[Cont]) - 1,
			 vp.right, vp.top + DELTA_Y(Lin[Cont]) + 1 + alt, 1);

	    clearviewport();

	    setcolor(bea_color[14]);

	    outtextxy(  DELTA_X(50) - textwidth(menuVVM[Cont])/2, 2, menuVVM[Cont]);

	    Cont = (Cont + 1) % 2;

	    setviewport( vp.left , vp.top + DELTA_Y(Lin[Cont]) - 1,
			 vp.right, vp.top + DELTA_Y(Lin[Cont]) + 1 + alt, 1);

	    clearviewport();
	    setfillstyle(1, bea_color[14]);
	    floodfill(1,1,1);
	    setcolor(bea_color[0]);
	    outtextxy(  DELTA_X(50) - textwidth(menuVVM[Cont])/2, 2, menuVVM[Cont]);
	    }
      } while(sc.ch[0] != ENTER);

   setviewport(vp.left,vp.top,vp.right,vp.bottom,1);

   return(Cont);
   }  /* MenuVentVolMax */
Exemplo n.º 29
0
int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int t,i,k,numeros;

   /* 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 */
   }



   outtextxy(116,60,"[1] *.bak");
   outtextxy(116,80,"[2] *.obj");
   outtextxy(116,100,"[3] *.exe [No recomendable]");
   outtextxy(116,120,"[4]  Todo [denegado ]");
   outtextxy(116,140,"Sin una opcion definida se hara el Default.");
   outtextxy(116,165,"Opcion ? [   ]");
   gotoxy(26,11);scanf("%d",&numeros);

   delay(700);
  cleardevice();

   for (t=1;t<=13;t++) {
   setcolor(t);
    outtextxy(150,20,"Escaneando la Unidad, tenga paciencia!");
    delay(60);
    }

    /* draw the 3-d bar */
      bar3d(100, 100, 400,140, 10, 1);

   /* loop through the fill patterns */
   k=0;
   for (i=100; i<=401; i++)
   {

      /* set the fill style */
      setfillstyle(1, BLUE);
      /* draw the bar */
    bar(100, 100, i,140);
    gotoxy (35,10);printf("%d%",k);
    k=(400-i);
    delay(10);
      }


   switch (numeros)  {

   case 1:
	system("dir *.bak");
	system("del *.bak");
	delay(700);
	break;

    case 2:
	system("dir *.obj");
	system("del *.obj");
	delay(700);
	break;

     case 3:
	system("dir *.exe");
	system("rename elimina.exe elimina.ira");
	system("del *.bak");
	system("rename elimina.ira elimina.exe");
	delay(700);
	break;

    case 4:
	system("dir *.*");
       gotoxy(25,25);printf("Esta funcion no esta activada, te jodes!");
	delay(900);
     //	system("del *.bak");
	break;

     default:
	gotoxy(25,25);printf("No es una opcion valida!");
	 delay(900);
    }



    cleardevice();
    settextstyle(5,0,4);
    for (t=1;t<=13;t++) {
    setcolor(t);
    outtextxy(150,20,"Unidad limpiada con exito!");
    delay(60);
    }
    settextstyle(8,0,3);
    for (t=1;t<=13;t++) {
    setcolor(t);
    outtextxy(150,300,"Presione una tecla para finalizar!");
    delay(60);
    }

    getch();
   /* clean up */
   closegraph();
   return 0;
}
Exemplo n.º 30
0
int main (int argc, char* argv [])
{
   #define check(ol, al) if (argv [i][ol] || \
                             badarg(argc - i - 1,argv + i + 1, al)) \
                            goto badopt
                            
   #define check_bool(olen, var) switch (argv [i][olen]) { \
                             case '\0': var = !var; break; \
                             case 'y': case 'Y': case 't': case 'T': \
                             case '+': case '1': var = 1; break; \
                             case 'n': case 'N': case 'f': case 'F': \
                             case '-': case '0': var = 0; break; \
                             default: goto badopt; \
                          }   

   int loadflags = IO_CHECK | IO_SCENE | IO_TREE | IO_BOUNDS, rval, i, j, n;
   char **portLp = photonPortList, **sensLp = photonSensorList,
        **amblp = NULL;
   struct stat pmstat;

   /* Global program name */
   progname = fixargv0(argv [0]);
   /* Initialize object types */
   initotypes();
   
   /* Parse options */
   for (i = 1; i < argc; i++) {
      /* Eggs-pand arguments */
      while ((rval = expandarg(&argc, &argv, i)))
         if (rval < 0) {
            sprintf(errmsg, "cannot eggs-pand '%s'", argv [i]);
            error(SYSTEM, errmsg);
         }
         
      if (argv[i] == NULL) 
         break;
         
      if (!strcmp(argv [i], "-version")) {
         puts(VersionID);
         quit(0);
      }
      
      if (!strcmp(argv [i], "-defaults") || !strcmp(argv [i], "-help")) {
         printdefaults();
         quit(0);
      }
      
      /* Get octree */
      if (i == argc - 1) {
         octname = argv [i];
         break;
      }
            
      switch (argv [i][1]) {
         case 'a': /* Ambient */
            switch (argv [i][2]) {
               case 'i': /* Ambient include */
               case 'I':
                  check(3, "s");
                  if (ambincl != 1) {
                     ambincl = 1;
                     amblp = amblist;
                  }
                  if (argv [i][2] == 'I') {	
                     /* Add modifiers from file */
                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
                                     getpath(argv [++i], 
                                     getrlibpath(), R_OK));
                     if (rval < 0) {
                        sprintf(errmsg, 
                                "cannot open ambient include file \"%s\"",
                                argv [i]);
                        error(SYSTEM, errmsg);
                     }
                     amblp += rval;
                  } 
                  else {
                     /* Add modifier from next arg */
                     *amblp++ = savqstr(argv [++i]);
                     *amblp = NULL;
                  }
                  break;

               case 'e': /* Ambient exclude */
               case 'E':
                  check(3, "s");
                  if (ambincl != 0) {
                     ambincl = 0;
                     amblp = amblist;
                  }
                  if (argv [i][2] == 'E') { 
                     /* Add modifiers from file */
                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
                                     getpath(argv [++i], 
                                     getrlibpath(), R_OK));
                     if (rval < 0) {
                        sprintf(errmsg,
                                "cannot open ambient exclude file \"%s\"", 
                                argv [i]);
                        error(SYSTEM, errmsg);
                     }
                     amblp += rval;
                  } 
                  else {
                     /* Add modifier from next arg */ 
                     *amblp++ = savqstr(argv [++i]);
                     *amblp = NULL;
                  }
                  break;
            
               case 'p': /* Pmap-specific */
                  switch (argv [i][3]) {			
                     case 'g': /* Global photon map */
                        check(4, "ss");
                        globalPmapParams.fileName = argv [++i];
                        globalPmapParams.distribTarget = 
                           parseMultiplier(argv [++i]);
                        if (!globalPmapParams.distribTarget) 
                           goto badopt;                         
                        globalPmapParams.minGather = 
                           globalPmapParams.maxGather = 0;
                        break;
            
                     case 'p': /* Precomputed global photon map */
                        check(4, "ssi");
                        preCompPmapParams.fileName = argv [++i];
                        preCompPmapParams.distribTarget = 
                           parseMultiplier(argv [++i]);
                        if (!preCompPmapParams.distribTarget) 
                           goto badopt;
                        preCompPmapParams.minGather = 
                           preCompPmapParams.maxGather = atoi(argv [++i]);
                        if (!preCompPmapParams.maxGather) 
                           goto badopt;
                        break;
            
                     case 'c': /* Caustic photon map */
                        check(4, "ss");
                        causticPmapParams.fileName = argv [++i];
                        causticPmapParams.distribTarget = 
                           parseMultiplier(argv [++i]);
                        if (!causticPmapParams.distribTarget) 
                           goto badopt;
                        break;
                  
                     case 'v': /* Volume photon map */
                        check(4, "ss");
                        volumePmapParams.fileName = argv [++i];
                        volumePmapParams.distribTarget = 
                           parseMultiplier(argv [++i]);
                        if (!volumePmapParams.distribTarget) 
                           goto badopt;                      
                        break;
                     
                     case 'd': /* Direct photon map */
                        check(4, "ss");
                        directPmapParams.fileName = argv [++i];
                        directPmapParams.distribTarget = 
                           parseMultiplier(argv [++i]);
                        if (!directPmapParams.distribTarget) 
                           goto badopt;
                        break;
                     
                     case 'C': /* Contribution photon map */
                        check(4, "ss");
                        contribPmapParams.fileName = argv [++i];
                        contribPmapParams.distribTarget =
                           parseMultiplier(argv [++i]);
                        if (!contribPmapParams.distribTarget)
                           goto badopt;
                        break;

                     case 'D': /* Predistribution factor */
                        check(4, "f");
                        preDistrib = atof(argv [++i]);
                        if (preDistrib <= 0)
                           error(USER, "predistrib factor must be > 0");
                        break;

                     case 'M': /* Max predistribution passes */
                        check(4, "i");
                        maxPreDistrib = atoi(argv [++i]);
                        if (maxPreDistrib <= 0)
                           error(USER, "max predistrib passes must be > 0");
                        break;

#if 1
                     /* Kept for backwards compat, to be phased out by -lr */
                     case 'm': /* Max photon bounces */
                        check(4, "i");
                        photonMaxBounce = atol(argv [++i]);
                        if (photonMaxBounce <= 0) 
                           error(USER, "max photon bounces must be > 0");
                        break;
#endif

#ifdef PMAP_EKSPERTZ                     
                     case 'i': /* Add region of interest */
                        check(4, "ffffff");                        
                        n = pmapNumROI;
                        pmapROI = realloc(pmapROI,
                                          ++pmapNumROI * sizeof(PhotonMapROI));
                        if (!pmapROI)
                           error(SYSTEM, "failed to allocate ROI");
                        pmapROI [n].min [0] = atof(argv [++i]);
                        pmapROI [n].min [1] = atof(argv [++i]);
                        pmapROI [n].min [2] = atof(argv [++i]);
                        pmapROI [n].max [0] = atof(argv [++i]);
                        pmapROI [n].max [1] = atof(argv [++i]);
                        pmapROI [n].max [2] = atof(argv [++i]);                        
                        for (j = 0; j < 3; j++)
                           if (pmapROI [n].min [j] >= pmapROI [n].max [j])
                              error(USER, "invalid region of interest "
                                    "(swapped min/max?)");
                        break;
#endif             

                     case 'P': /* Global photon precomp ratio */
                        check(4, "f");
                        finalGather = atof(argv [++i]);
                        if (finalGather <= 0 || finalGather > 1)
                           error(USER, "global photon precomputation ratio "
                                 "must be in range ]0, 1]");
                        break;
                     
                     case 'o': /* Photon port */ 
                     case 'O':
                        check(4, "s");
                        if (argv [i][3] == 'O') {	
                           /* Add port modifiers from file */
                           rval = wordfile(portLp, 
                                           MAXSET - (portLp - photonPortList),
                                           getpath(argv [++i],
                                           getrlibpath(), R_OK));
                           if (rval < 0) {
                               sprintf(errmsg, 
                                       "cannot open photon port file %s", 
                                       argv [i]);
                               error(SYSTEM, errmsg);
                           }
                           portLp += rval;
                        } 
                        else {
                           /* Add port modifier from next arg, mark end with
                            * NULL */
                           *portLp++ = savqstr(argv [++i]);
                           *portLp = NULL;
                        }
                        break;
                     
                     case 'r': /* Random seed */
                        check(4, "i");
                        randSeed = atoi(argv [++i]);
                        break;                   

                     case 's': /* Antimatter sensor */ 
                     case 'S':
                        check(4, "s");
                        if (argv[i][3] == 'S') {	
                           /* Add sensor modifiers from file */
                           rval = wordfile(sensLp, 
                                           MAXSET - (sensLp - photonSensorList),
                                           getpath(argv [++i], 
                                           getrlibpath(), R_OK));
                           if (rval < 0) {
                               sprintf(errmsg, 
                                       "cannot open antimatter sensor file %s",
                                       argv [i]);
                               error(SYSTEM, errmsg);
                           }
                           sensLp += rval;
                        } 
                        else {
                           /* Append modifier to sensor list, mark end with
                            * NULL */
                           *sensLp++ = savqstr(argv [++i]);
                           *sensLp = NULL;
                        }
                        break;

                     default: goto badopt;
                  }
                  break;
                  
               default: goto badopt;
            }
            break;
                
         case 'b': /* Back face visibility */
            if (argv [i][2] == 'v') {
               check_bool(3, backvis);
            }
            else goto badopt;
            break;
                   
         case 'd': /* Direct */
            switch (argv [i][2]) {
               case 'p': /* PDF samples */
                  check(3, "f");
                  pdfSamples = atof(argv [++i]);
                  break;
                  
               case 's': /* Source partition size ratio */
                  check(3, "f");
                  srcsizerat = atof(argv [++i]);
                  break;
                  
               default: goto badopt;
            }                   
            break;
                   
         case 'e': /* Diagnostics file */
            check(2, "s");
            diagFile = argv [++i];
            break;
                  
         case 'f': /* Force overwrite */
            if (argv [i][2] == 'o') {
               check_bool(3, clobber);
            }
            else goto badopt;
            break; 

#ifdef PMAP_EKSPERTZ
         case 'l': /* Limits */
            switch (argv [i][2]) {
               case 'd': /* Limit photon path distance */
                  check(3, "f");
                  photonMaxDist = atof(argv [++i]);
                  if (photonMaxDist <= 0)
                     error(USER, "max photon distance must be > 0");
                  break;
                 
               case 'r': /* Limit photon bounces */               
                  check(3, "i");               
                  photonMaxBounce = atol(argv [++i]);
                  if (photonMaxBounce <= 0) 
                     error(USER, "max photon bounces must be > 0");
                  break;
               
               default: goto badopt;
            }
            break;
#endif

         case 'm': /* Medium */
            switch (argv[i][2]) {
               case 'e':	/* Eggs-tinction coefficient */
                  check(3, "fff");
                  setcolor(cextinction, atof(argv [i + 1]),
                           atof(argv [i + 2]), atof(argv [i + 3]));
                  i += 3;
                  break;
                                
               case 'a':	/* Albedo */
                  check(3, "fff");
                  setcolor(salbedo, atof(argv [i + 1]), 
                           atof(argv [i + 2]), atof(argv [i + 3]));
                  i += 3;
                  break;
                                
               case 'g':	/* Scattering eccentricity */
                  check(3, "f");
                  seccg = atof(argv [++i]);
                  break;
                                
               default: goto badopt;
            }                   
            break;
            
#if NIX
         case 'n': /* Num parallel processes (NIX only) */
            check(2, "i");
            nproc = atoi(argv [++i]);
            
            if (nproc > PMAP_MAXPROC) {
               nproc = PMAP_MAXPROC;
               sprintf(errmsg, "too many parallel processes, clamping to "
                       "%d\n", nproc);
               error(WARNING, errmsg);
            }            
            break;                   
#endif

         case 't': /* Timer */
            check(2, "i");
            photonRepTime = atoi(argv [++i]);
            break;
            
         case 'v':   /* Verbosity */
            check_bool(2, verbose);
            break;
            
#ifdef EVALDRC_HACK
         case 'A':   /* Angular source file */
            check(2,"s");
            angsrcfile = argv[++i];
            break;                   
#endif

        default: goto badopt;
      }
   }
   
   /* Open diagnostics file */
   if (diagFile) {
      if (!freopen(diagFile, "a", stderr)) quit(2);
      fprintf(stderr, "**************\n*** PID %5d: ", getpid());
      printargs(argc, argv, stderr);
      putc('\n', stderr);
      fflush(stderr);
   }
   
#ifdef NICE
   /* Lower priority */
   nice(NICE);
#endif

   if (octname == NULL) 
      error(USER, "missing octree argument");
      
   /* Allocate photon maps and set parameters */
   for (i = 0; i < NUM_PMAP_TYPES; i++) {
      setPmapParam(photonMaps + i, pmapParams + i);
      
      /* Don't overwrite existing photon map unless clobbering enabled */
      if (photonMaps [i] && !stat(photonMaps [i] -> fileName, &pmstat) &&
          !clobber) {
         sprintf(errmsg, "photon map file %s exists, not overwritten",
                 photonMaps [i] -> fileName);
         error(USER, errmsg);
      }
   }
       
   for (i = 0; i < NUM_PMAP_TYPES && !photonMaps [i]; i++);   
   if (i >= NUM_PMAP_TYPES)
      error(USER, "no photon maps specified");
   
   readoct(octname, loadflags, &thescene, NULL);
#ifdef EVALDRC_HACK   
   if (angsrcfile)
      readobj(angsrcfile);    /* load angular sources */
#endif         
   nsceneobjs = nobjects;
   
   /* Get sources */
   marksources();

   /* Do forward pass and build photon maps */
   if (contribPmap)
      /* Just build contrib pmap, ignore others */
      distribPhotonContrib(contribPmap, nproc);
   else
      distribPhotons(photonMaps, nproc);
   
   /* Save photon maps; no idea why GCC needs an explicit cast here... */
   savePmaps((const PhotonMap**)photonMaps, argc, argv);
   cleanUpPmaps(photonMaps);
   
   quit(0);

badopt:
   sprintf(errmsg, "command line error at '%s'", argv[i]);
   error(USER, errmsg);

   #undef check
   #undef check_bool
   return 0;
}