Exemple #1
0
void main()
{
	int gm,gd;
	printf("Enter line co ordinates x1 y1 x2 y2");
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	printf("Enter window co ordinates xw1,yw1,xw2,yw2");
	scanf("%d %d %d %d",&w[0],&w[1],&w[4],&w[5]);
	detectgraph(&gd,&gm);
    initgraph(&gd,&gm,"C:\\TURBOC3\\bgi");
	w[2]=w[4];
	w[3]=w[1];
	w[6]=w[0];
	w[7]=w[5];
	w[8]=w[0];
	w[9]=w[1];
	line(x1,y1,x2,y2);
	drawpoly(5,w);

	cohen();
	getch();
	closegraph();
	detectgraph(&gd,&gm);
    initgraph(&gd,&gm,"C:\\TURBOC3\\bgi");

	line(x1,y1,x2,y2);
	drawpoly(5,w);
	getch();

}
void main(void)
{
	int tarj,modo,x=320,y=240,c=1;
	unsigned int segment, offst;
	detectgraph(&tarj,&modo);
	initgraph(&tarj,&modo,"c:\\tc\\bgi");
	setcolor(0);
	setfillstyle(1,c);
	do
	{
		t=inport(0x60); /* Leemos la entrada del teclado */
		switch (t)
		{
			case 28: /* Si se ha pulsado INTRO */
				if (c<15) c++;
				else c=1;
				setfillstyle(1,c); /* Cambiamos el color del c¡rculo */
				break;
			case 72: /* Cursor arriba */
				y--; break;
			case 75:
				x--; break; /* Cursor izquierda */
			case 77:
				x++; break; /* Cursor derecha */
			case 80:
				y++; break; /* Cursor abajo */
		}
		fillellipse(x,y,40,40); /* dibujamos el c¡rculo */

		/* Esta es una forma pr ctica de borrar la pantalla sin excesivos
			parpadeos */
		*(char far *) MK_FP(0x40,0x1a)=*(char far *) MK_FP(0x40,0x1c);
        }while(t!=1); /* Mientras no se pulse ESC */
}
Exemple #3
0
void main()
{
 int gd,gm,sx,sy,i,j,v;
 int x[10],y[10],a[10],b[10];

 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");

 printf("enter number of vertices\n");
 scanf("%d",&v);

 printf("enter d cordinates\n");

 for(i=0;i<v;i++)
 {
  printf("enter x and y cordinates\n");
  scanf("%d%d",&x[i],&y[i]);
 }

 printf("enter sx and sy\n");
 scanf("%d%d",&sx,&sy);

  for(i=0;i<v-1;i++)
 {
  line(x[i],y[i],x[i+1],y[i+1]);
  line(x[i]*sx,y[i]*sy,x[i+1]*sx,y[i+1]*sy);
 }
 line(x[0],y[0],x[v-1],y[v-1]);
 line(x[0]*sx,y[0]*sy,x[v-1]*sx,y[v-1]*sy);

 getch();
 closegraph();
}
void main()
{
int x1,x2,y1,y2,gd,gm,opt;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tcc\\bgi");
cout<<"Enter the Co-ordinate of 1st End Point ";
cin>>x1>>y1;
cout<<"\n Enter the Co-ordinate of 2nd End Point ";
cin>>x2>>y2;
cout<<"Enter No to draw line by prefered algorithm "<<endl;

cout<<"Your options are 1.  DDA "<<endl<<"2.  Bresenhams "<<endl<<"Your options are 1 or 2 ";
cin>>opt;
if (opt==1)
{
cleardevice();
cout<<"DDA Line Aloforiyhm "<<endl;
ddaline(x1,y1,x2,y2);
}
else
{
cleardevice();
cout<<"Bresenhams Line Drawing Algorithm  "<<endl;
bresline(x1,y1,x2,y2);
}
getch();
closegraph();

}
void main()
{
 clrscr();
 float x,y,r,d,xc,yc;
 int gd,gm;
 cout<<"Enter radius of the circle\n";
 cin>>r;
 cout<<"Enter co-ordinates of the center\n";
 cin>>xc>>yc;
 xc=320+xc;
 yc=240-yc;
 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"");
 line(320,0,320,480);
 line(0,240,640,240);
 x=0;
 y=r;
 d=3-2*r;
 do
 {
  display(xc,yc,x,y);
  if(d<0)
   d=d+4*x+6;
  else
  {
   d=d+4*(x-y)+10;
   y=y-1;
  }
  x=x+1;
 }while(x<y);
 getch();
}
void opengraph(void)
   {
      int driver, mode;

      detectgraph(&driver, &mode);
      initgraph(&driver, &mode, "c:\\borlandc\\bgi");
   }
void initialize()
{
 int gd,gm;
 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"");
 line(320,0,320,480);
 line(0,240,640,240);
}
Exemple #8
0
void main(){
	int gDriver=DETECT,gMode;
	detectgraph(&gDriver,&gMode);
	initgraph(&gDriver,&gMode,"");
	Game g;
	g.gameHandler();
	getch();
}
Exemple #9
0
void main()
{
	int a=0,gd,gm,x,y,i=0,d=1000,sp=0,m=0,h=0,seth=0,setm=0;
	int pts[2][2],ptsm[2][2],ptsh[2][2];
	struct  time t;

	gettime(&t);
	 printf("The current time is: %2d:%02d:%02d.%02d\n",
	  t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
	seth=t.ti_hour;
	if(seth>=12)
	seth-=12;
	setm=t.ti_min;
	detectgraph(&gd,&gm);
	initgraph(&gd,&gm,"c://tc/bgi");
	x=getmaxx();
	y=getmaxy();
	pts[0][0]=ptsm[0][0]=ptsh[0][0]=1;
	pts[0][1]=ptsm[0][1]=ptsh[0][1]=1;
	pts[1][0]=ptsm[1][0]=ptsh[1][0]=1;
	pts[1][1]=-100;
	ptsm[1][1]=-90;
	ptsh[1][1]=-80;
      //	printf("\n\nEnter time: ");
    //	scanf("%d %d",&seth,&setm);

	m=6*setm;
	h=(30*seth)+(setm/2);
	while(!kbhit())
	{
	cleardevice();
	outtextxy(270,80,"Analog Clock");
	circle(x/2,y/2,3);
	circle(x/2,y/2,120);
	line(x/2,y/2-115,x/2,y/2-120);
	line(x/2-115,y/2,x/2-120,y/2);
	line(x/2+115,y/2,x/2+120,y/2);
	line(x/2,y/2+115,x/2,y/2+120);
	rotate(pts,a);
	rotate(ptsm,m);
	rotate(ptsh,h);
	a+=6;

	if(a==360)
	{

	m+=6;
	a=0;
	if(m>=12&&m%12==0)
		h+=1;
	}

	delay(d);
	}
	getch();
	return;
}
/* function prototypes */
int huge detectSVGA256(void)
{
	int driver, mode;
	detectgraph(&driver, &mode);
	if (driver == VGA)
	return  4 ;
	else
	return grError;
}
void main()
{
    int gd,gm,x,y,z,o,x1,x2,y1,y2;
    detectgraph(&gd,&gm);
    initgraph(&gd,&gm,"e:\tc\bgi");

    setfillstyle(0,getmaxcolor());
    maxx=getmaxx();
    maxy=getmaxy();
    midx=maxx/2;
    midy=maxy/2;

    axis();

    bar3d(midx+50,midy-100,midx+60,midy-90,5,1);

    printf("Enter translation factor");
    scanf("%d%d",&x,&y);
    axis();
    printf("\nAfter translation: ");
    bar3d(midx+x+50,midy-(y+100),midx+x+60,midy-(y+90),5,1);

    axis();
    bar3d(midx+50,midy-100,midx+60,midy-90,5,1);
    printf("\nEnter scaling factors: " );
    scanf("%d%d%d", &x,&y,&z);

    axis();
    printf("After scaling: ");
    bar3d(midx+(x*50),midy-(y*100),midx+(x*60),midy-(y*90),5*z,1);
    axis();


    bar3d(midx+50,midy-100,midx+60,midy-90,5,1);

    printf("\nEnter rotating angle: " );
    scanf("%d",&o);
    x1=50*cos(o*3.14/180)-100*sin(o*3.14/180);
    y1=50*sin(o*3.14/180)+100*cos(o*3.14/180);
    x2=60*cos(o*3.14/180)-90*sin(o*3.14/180);
    y2=60*sin(o*3.14/180)+90*cos(o*3.14/180);

    axis();
    printf("After rotation about z axis");
    bar3d(midx+x1,midy-y1,midx+x2,midy-y2,5,1);
    axis();

    printf("\nAfter rotation  about x axis: ");
    bar3d(midx+50,midy-x1,midx+60,midy-x2,5,1);

    axis();
    printf("\nAfter rotation about yaxis: ");
    bar3d(midx+x1,midy-100,midx+x2,midy-90,5,1);
    getch();
    closegraph();
}
Exemple #12
0
void igraph()
{
 detectgraph(&gd,&gm);
 if(gd<0)
 {
  puts("CANNOT DETECT A GRAPHICS CARD");
  exit(1);
 }
 initgraph(&gd,&gm,"C:\\Turboc3\\BGI");
}
void main()
{
     int gd,gm,i;
     detectgraph(&gd,&gm);
     initgraph(&gd,&gm,"c:\\tc\\bgi");
     wheel();                          //for loading
     home_draw();		    // for home page design
     profile_draw();
     closegraph();
}
void main()
{
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tcc\\bgi");
rectangle(50,50,100,100);
flood(55,55,4,15);
getch();
closegraph();
}
void main()
{
int x1,y1,x2,y2,dx,dy,p,x,y;
int gd=DETECT ,gm;
printf("enter coordinates x1 and y1");
scanf("%d%d",&x1,&y1);
printf("enter  the coordinates x2 and y2");
scanf( "%d%d",&x2,&y2);
dx = (x2-x1);
dy =( y2-y1);
p = 2*(dy) -( dx);
x = x1;
y = y1;
detectgraph(&gd,&gm);
initgraph(&gd,&gm," ");
putpixel(x,y,4);
if(dx>dy){
while(x<=x2)     {

if(p<0)
{
x = x+1;
y = y;
p = p + 2*(dy);
}
else
{
x = x+1;
y = y+1;
p = p+2*(dy-dx);
}
putpixel(x,y,4);} }
else
{
while(y<=y2)     {

if(p<0)
{
y = y+1;
x = x;
p = p + 2*(dx);
}
else
{
y = y+1;
x = x+1;
p = p+2*(dx-dy);
}
putpixel(x,y,4);}
}
getch();
closegraph();
}
Exemple #16
0
int main()
{
	int gdrive, gmode;
	char *drvpath = "c:\\bc\\bgi";
	detectgraph(&gdrive, &gmode);
	initgraph(&gdrive, &gmode, drvpath);
	setbkcolor(0);
	setcolor(2);
	cleardevice();
	MyOwnFan(320, 230, 0);
	getch();
	closegraph();
	return 0;
}
Exemple #17
0
void main()
{
	int gdriver = DETECT, gmode;
	int x,j,y,x1,y1,x2,y2,i,dx,dy,p;
	clrscr();
	detectgraph(&gdriver, &gmode);
	initgraph(&gdriver, &gmode, "C:\\TC\\BGI");
	cout<<"starting points";
	cin>>x1>>y1;
	cout<<"destination points";
	cin>>x2>>y2;
	x=x1;
	y=y1;
	dx=x1-x;
	dy=y1-y;
	p=2*dy-dx;
	putpixel(x,y,WHITE);
	while(x<=x2)
	{

		x++;
		if(p<0)
		{

		    p=p+2*dy;

	       }
		else
		{
			y++;
			p=p+2*(dy-dx);


		}
			putpixel(x,y,BLUE);


	}
       for(i=0;i<=100;i++)
       {
       for(j=0;j<=10;j++)
       {
       putpixel(x-2*i,y-2*i,j);
       }
       }
	getch();

	closegraph();
	getch();}
Exemple #18
0
main()
{
int driver, mode;
int status;
char buf[1000];

	defsources ();

/*
	driver=HERCMONO;
	mode=HERCMONOHI;
*/
/*
	printf ("Driver ? ");
	scanf ("%d", &driver);
	printf ("Mode ? ");
	scanf ("%d", &mode);
*/
	detectgraph (&driver, &mode);
#ifdef GRAPH
	initgraph (&driver, &mode, "");
	status = graphresult ();
	if (status != grOk)
	{
		printf ("Erreur initgraph %d 0x%X\n", status, status);
		return;
	}
#endif
/*
	putpixel (120, 130, 1);
	{
	int i;
		for (i=0; i<150; i++)
		{
			putpixel (i, i, 1);
		}
	}
*/
	interf ();

	gets (buf);
	sleep (1);
	restorecrtmode ();
	printf ("status = %d\n", status);
}
int main(){
	int dx,dy,x,y,p,x1,y1,x2,y2;
	int gd,gm;

	printf("Enter the value of x1 : ");
	scanf("%d",&x1);
	printf("Enter the value of y1 : ");
	scanf("%d",&y1);
	printf("Enter the value of x2 : ");
	scanf("%d",&x2);
	printf("Enter the value of y1 : ");
	scanf("%d",&y2);

	dx = x2 - x1;
	dy = y2 - y1;

	p = 2 * dy - dx;

	x = x1;
	y = y1;

	detectgraph(&gd,&gm);
	initgraph(&gd,&gm,"");
	setbkcolor(WHITE);
	putpixel(x,y,0);

	while(x <= x2){
		if(p < 0){
			x=x+1;
			y=y;
			p = p + 2 * (dy);
		}
		else{
			x=x+1;
			y=y+1;
			p = p + 2 * (dy - dx);
		}
		putpixel(x,y,0);
	}

	getch();
	closegraph();

}
Boolean graphAppInit( int aDriver, int aMode,
            char *aBGIPath, Boolean loadAtInit )
{
    if (aBGIPath != 0)
        bgiPath = aBGIPath;
    driver = aDriver;
    mode = aMode;
    freeDriverMem();
    if ( loadAtInit == True )
        {
        if ( driver == 0 )
            detectgraph(&driver, &mode);
        if ( driver > 0 )
            return graphAppLoadDriver(driver);
        else
            return False;
        }
    return(True);
}
Exemple #21
0
int main(){
int i,gd,gm,j,counter;
int r;
r=50;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"../BGI");
counter=0;
for(i=50;i<=250;i++)
{
counter++;
clrscr();
setcolor(rand());
circle(i,250,r);
circle(500-i,250,r+50);
line(150,250,350,250);
line(150,250,250,150);
line(350,250,250,150);
line(150,250,250,350);
line(350,250,250,350);
line(250,150,250,350);
line(200,300,300,200);
line(300,300,200,200);
line(300,300,200,300);
line(200,200,300,200);
line(200,200,200,300);
line(300,200,300,300);
delay(50);
if(counter==1){
for(j=50;j<250;j++)
{
clrscr();
setcolor(rand());
circle(250,j,r);
circle(250,500-j,r+50);
delay(50);
} }
}
delay(200);
closegraph();
return 0;
}
Exemple #22
0
int InitGraphics()
{
    int grd, grm;
    int gresult;
    // Detect the graphics driver and mode
    detectgraph(&grd,&grm);
    // initialize the graphics mode with initgraph
    initgraph(&grd, &grm, "c:\\TC\\BGI");
    gresult = graphresult();
    if(gresult != grOk)
    {
        printf(grapherrormsg(gresult));
	getch();
        return -1;
    }
    // set the background color
    setbkcolor(BLACK);
    // set the foreground color
    setcolor(WHITE);
    return 1;
}
Exemple #23
0
main()
{
  int gd=DETECT,gm;
  int i;
  unsigned long t;
  double alfa=0;
  double x,y;
  int time;
  detectgraph(&gd,&gm);
  initgraph(&gd,&gm,"");
  setbkcolor(BLACK);
  setcolor(WHITE);
  x=0;
  y=0;
  moveto(x*40+20,y*100+300);
  for(x=0;x<15;x=x+0.1)
  {
    y=sin(x+alfa);
    lineto(x*40+20,y*100+300);
  }
  getch();
  closegraph();
}
Exemple #24
0
void main()
{
	float wx,wy,x1,x2,y1,y2,slope;
	int gd =DETECT,gm,i,thickness;
	clrscr();

	printf("Enter the two points\n");
	scanf("%f %f",&x1,&y1);
	scanf("%f %f",&x2,&y2);

	detectgraph(&gd,&gm);
	initgraph(&gd,&gm,"C:\\TurboC3\\BGI");

	printf("Enter the reqd. thickness\n");
	scanf("%d",&thickness);
	cleardevice();
	slope=(float)(y2-y1)/(x2-x1);
	for(i=1;i<thickness;i++)
		drawline(x1+i*slope,y1-i*slope,x2+i*slope,y2-i*slope);

	getch();
	closegraph();
}
Exemple #25
0
void main()
{
	int gd,gm,v,i;
	float thetha,x[10],y[10];
	int x1[30];
	clrscr();
	printf("Enter the no. of vertices\n");
	scanf("%d",&v);
	printf("Enter the co ordinates");
	for(i=0;i<v;i++)
		scanf("%f %f",&x[i],&y[i]);
	printf("Enter the angle of rotation\n");
	scanf("%f",&thetha);
	thetha=(thetha*3.142/180);
	for(i=0;i<2*v;i=i+2)
	{
		x1[i]=x[i]*cos(thetha)-y[i]*sin(thetha);
		x1[i+1]=x[i]*sin(thetha)+y[i]*cos(thetha);
		printf("%d %d ",x[i],x[i+1]);
		//x[i+1]*cos(thetha)-y[i+1]*sin(thetha);
		//x[i+1]*sin(thetha)+y[i+1]*cos(thetha);
	}
	x1[2*v]=x1[0];
	x1[2*v+1]=x1[1];
	detectgraph(&gd,&gm);
	initgraph(&gd,&gm,"C://TURBOC3//BGI");
	for(i=0;i<v-1;i++)
	{
		line(x[i],y[i],x[i+1],y[i+1]);
	}
	line(x[0],y[0],x[v-1],y[v-1]);
	getch();
	drawpoly(v,x1);
	//line();
	getch();
       //	closegraph();
}
int main()
{
 int i, x, y, tx, ty, sx, sy, angle=10, xmax, ymax, xmid, ymid, op;
 int gd,gm;
 float p1[10]= { 50,50,
     100,50,
     100,100,
     50,100,
     50,50,
 };
 int pi[10];
 float b[3][3]={ 1,0,0,
     0,1,0,
     0,0,1
 };
 int c[1][1];
 float a[1][1];
 printf("\nSelect the transformation : ");
 printf("\n1 : Translation");
 printf("\n2 : Rotation");
 printf("\n3 : Scaling");
 printf("\n4 : Rotation about arbitrary point");
 printf( "\nEnter the option : ");
 scanf("%d",&op);
 switch(op)
 {
  case 1: printf("\nEnter x translation : ");
  scanf("%d",&tx);
  printf("\nEnter y translation : ");
  scanf("%d",&ty);
  
  b[0][0] = 1;
  b[0][1] = 0;
  b[0][2] = 0;
  
  b[1][0] = 0;
  b[1][1] = 1;
  b[1][2] = 0;
  
  b[2][0] = tx;
  b[2][1] = ty;
  b[2][2] = 1;
  
  break;
  case 2: printf("\nEnter Rotation angle : ");
  scanf("%d",&angle);
  b[0][0] =cos(angle*3.142/180);
  b[0][1] =sin(angle*3.142/180);
  b[0][2] = 0;
  
  b[1][0] =-sin(angle*3.142/180);
  b[1][1] = cos(angle*3.142/180);
  b[1][2] = 0;
  
  b[2][0] = 0;
  b[2][1] = 0;
  b[2][2] = 1;
  
  break;
  case 3: printf("\nEnter x scaling : ");
  scanf("%d",&sx);
  printf("\nEnter y scaling : ");
  scanf("%d",&sy);
  
  b[0][0] = sx;
  b[0][1] = 0;
  b[0][2] = 0;
  
  b[1][0] = 0;
  b[1][1] = sy;
  b[1][2] = 0;
  
  b[2][0] = 0;
  b[2][1] = 0;
  b[2][2] = 1;
  
  break;
  case 4: printf("\nEnter x coordinate of arbitrary point : ");
  scanf("%d",&x);
  printf("\nEnter y coordinate of arbitrary point : ");
  scanf("%d",&y);
  printf("\nEnter Rotation angle : ");
  scanf("%d",&angle);
  
  tx = x;
  ty = y;
  
  b[0][0] =cos(angle*3.142/180);
  b[0][1] =sin(angle*3.142/180);
  b[0][2] = 0;
  
  b[1][0] =-sin(angle*3.142/180);
  b[1][1] = cos(angle*3.142/180);
  b[1][2] = 0;
  
  b[2][0] = -tx* cos(angle*3.142/180) + ty*sin(angle*3.142/180)+tx;
  b[2][1] = -tx* sin(angle*3.142/180) - ty*cos(angle*3.142/180)+ty;
  b[2][2] = 1;
     
 }
 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"C:\\Turboc3\\BGI"); // Initialize graphics
 xmax = getmaxx(); // Get maximum x coordinate
 ymax = getmaxy(); // Get maximum y coordinate
 xmid = xmax/2; // Get the center x coordinate
 ymid = ymax/2; // Get the center y coordinate
 
 setcolor(1);
 line(xmid,0,xmid,ymax); // Draw y coordinate
 line(0, ymid, xmax, ymid); // Draw x coordinate
 
 setcolor(4);
 for (i=0; i<8;i=i+2)
 {
  line(p1[i]+xmid,ymid-p1[i+1],xmid+p1[i+2],ymid-p1[i+3]);
 }
 for(i=0;i<9;i=i+2)
 { 
  a[0][0]=p1[i];
  a[0][1]=p1[i+1];
  c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+b[2][0];
  c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+b[2][1];
  pi[i]=c[0][0];
  pi[i+1]=c[0][1];
 }
 setcolor(15);
 for (i=0; i<8;i=i+2)
 {
  line(xmid+pi[i],ymid-pi[i+1],xmid+pi[i+2],ymid-pi[i+3]);
 }
 getch();
 closegraph();
 return 0;
}
Exemple #27
0
void igraph()
{
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
}
Exemple #28
0
void init()
{
 int gd,gm;
 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"");
}
   void main(void)
   {

   int graphmode, graphdriver;
   int curr_mode;

   int posx, posy, dest, x, y;
   int cx, cy, cr;
   float FI, PI, RAIO, RO, TETA,TETA2, X0, Y0, XL, YL, XL1, YL1;
   char tecla;
   int a, b,I;


   detectgraph (&graphdriver, &graphmode);

   initgraph (&graphdriver, &graphmode, "c:\\borlandc\\bgi");


  do{

   PI = 3.14159265358979;
   X0 = 130;
   Y0 = 250;
   I = -90;
   RO = 0;
   FI = 0;
   RAIO=8;

   setfillstyle(1,LIGHTBLUE);
   floodfill(0,0,LIGHTBLUE);

   setcolor(GREEN);
   rectangle(0,280,700,600);
   setfillstyle(1,GREEN);
   floodfill(15,295,GREEN);
   // Arvore
   /*   setcolor(BROWN);
   rectangle(420,320,485,120);
   setfillstyle(1,BROWN);
   floodfill(420,320,BROWN); */
   setcolor(BROWN);
   outtextxy(425,110,"ллллллл");
   outtextxy(425,118,"ллллллл");
   outtextxy(425,126,"ллллллл");
   outtextxy(425,134,"ллллллл");
   outtextxy(425,142,"ллллллл");
   outtextxy(425,150,"ллллллл");
   outtextxy(425,158,"ллллллл");
   outtextxy(425,166,"ллллллл");
   outtextxy(425,174,"ллллллл");
   outtextxy(425,152,"ллллллл");
   outtextxy(425,160,"ллллллл");
   outtextxy(425,168,"ллллллл");
   outtextxy(425,176,"ллллллл");
   outtextxy(425,184,"ллллллл");
   outtextxy(425,192,"ллллллл");
   outtextxy(425,200,"ллллллл");
   outtextxy(425,208,"ллллллл");
   outtextxy(425,216,"ллллллл");
   outtextxy(425,224,"ллллллл");
   outtextxy(425,232,"ллллллл");
   outtextxy(425,240,"ллллллл");
   outtextxy(425,248,"ллллллл");
   outtextxy(425,256,"ллллллл");
   outtextxy(425,264,"ллллллл");
   outtextxy(425,272,"ллллллл");
   outtextxy(425,280,"ллллллл");
   outtextxy(425,288,"ллллллл");
   outtextxy(425,296,"ллллллл");
   outtextxy(425,304,"ллллллл");
   outtextxy(425,312,"ллллллл");

   setfillstyle(1,GREEN);
   setcolor(GREEN);
   circle(410,100,50);
   floodfill(410,100,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(490,100,50);
   floodfill(490,100,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(455,140,40);
   floodfill(455,140,GREEN);
   setfillstyle(1,GREEN);

   setcolor(GREEN);
   circle(455,60,40);
   floodfill(455,60,GREEN);
   setfillstyle(1,GREEN);

   //Alvo
   cx=450;
   cy=250;
   cr=50;



   setfillstyle(1,WHITE);

   //Nuvens
   setcolor(WHITE);
   circle(100,100,cr-40);
   floodfill(100,100,WHITE);
   setfillstyle(1,WHITE);

   setcolor(WHITE);
   circle(120,100,cr-35);
   floodfill(120,100,WHITE);
   setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(140,100,cr-40);
    floodfill(140,100,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(260,50,cr-35);
    floodfill(260,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(280,50,cr-30);
    floodfill(280,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(305,50,cr-30);
    floodfill(305,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(330,50,cr-35);
    floodfill(330,50,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(540,150,cr-45);
    floodfill(540,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(550,150,cr-42);
    floodfill(550,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(560,150,cr-42);
    floodfill(560,150,WHITE);
    setfillstyle(1,WHITE);

    setcolor(WHITE);
    circle(570,150,cr-45);
    floodfill(570,150,WHITE);
    setfillstyle(1,YELLOW);
    //Sol
    setcolor(YELLOW);
    circle(570,40,40);
    floodfill(570,40,YELLOW);
    setfillstyle(1,YELLOW);
    //Faca

    do{
    if(X0<=440)
    {
    if(X0==440)
    {
    setfillstyle(1,LIGHTBLUE);
    setcolor(LIGHTBLUE);
    setfillstyle(1,LIGHTBLUE);
    circle(cx,cy,cr);
    floodfill(cx,cy,LIGHTBLUE);
   }
   if((X0>405)&&(X0<420))
    {
    setfillstyle(1,RED);
    setcolor(RED);
    setfillstyle(1,RED);
    circle(cx,cy,cr);
    floodfill(cx,cy,RED);
   }

   if((X0<=135)||(X0==440))
   {setfillstyle(1,RED);
    setcolor(RED);
    circle(cx,cy,cr);
    floodfill(cx,cy,RED);
    setfillstyle(1,LIGHTGRAY);

    setcolor(LIGHTGRAY);
    circle(cx,cy,cr-10);
    floodfill(cx,cy,LIGHTGRAY);
    setfillstyle(1,RED);

   setcolor(RED);
   circle(cx,cy,cr-20);
   floodfill(cx,cy,RED);
   setfillstyle(1,LIGHTGRAY);

   setcolor(LIGHTGRAY);
   circle(cx,cy,cr-30);
   floodfill(cx,cy,LIGHTGRAY);
   setfillstyle(1,RED);

   setcolor(RED);
   circle(cx,cy,cr-40);
   floodfill(cx,cy,RED);
   }
    TETA = PI*I/180;
    XL = X0 + RAIO*cos(TETA)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA)*cos(PI*FI/180);
    XL1 = X0 - RAIO*cos(TETA)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA)*cos(PI*FI/180);
    /* setcolor(BLUE);
    line(X0,Y0,XL,YL);
    setcolor(BLUE);
    line(X0,Y0,XL1,YL1);*/

    setcolor(WHITE);
    line(X0,Y0,XL,YL);
    setcolor(BROWN);
    line(X0,Y0,XL1,YL1);

    //while (X0>=440);
    //if(X0>=440);

    if(X0<405)
    {
    TETA2 = PI*(I-3)/180;
    XL = X0-2 + RAIO*cos(TETA2)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA2)*cos(PI*FI/180);
    XL1 = X0-2 - RAIO*cos(TETA2)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA2)*cos(PI*FI/180);
    setcolor(LIGHTBLUE);
    line(X0-2,Y0,XL,YL);
    //setcolor(BROWN);
    line(X0-2,Y0,XL1,YL1);
    }
     if((X0>405) &&(X0<430))
    {
    TETA2 = PI*(I-3)/180;
    XL = X0-2 + RAIO*cos(TETA2)*cos(PI*RO/180);
    YL = Y0 + RAIO*sin(TETA2)*cos(PI*FI/180);
    XL1 = X0-2 - RAIO*cos(TETA2)*cos(PI*RO/180);
    YL1 = Y0 - RAIO*sin(TETA2)*cos(PI*FI/180);
    setcolor(RED);
    line(X0-2,Y0,XL,YL);
    line(X0-2,Y0,XL1,YL1);
    }
    }

   // cleardevice();
    I+=3;
    X0+=2;

    //Homem
    posx=150;
    posy=250;
    dest=10;
    setcolor(14);

    //Tronco
    setcolor(YELLOW);
    line(posx, posy+10, posx, posy+40);

    //Pernas
    line(posx, posy+40, posx+10, (posy+70));
    line(posx, posy+40, posx-10, (posy+70));

    //Bra‡os
    line(posx, posy+18, posx+20, posy+15);
    line(posx, posy+18, posx-15, posy+35);

    //Bra‡o mexendo
    if(X0<=200)
    {
    setcolor(LIGHTBLUE);
    a = (int)( posx+10 + 20*cos(TETA2)*cos(PI*0/180));
    b = (int)( posy+10 + 20*sin(TETA2)*cos(PI*0/180));
    line(posx+20, posy+15, a, b);

    setcolor(YELLOW);
    a = (int)( posx+10 + 20*cos(TETA)*cos(PI*0/180));
    b = (int)( posy+10 + 20*sin(TETA)*cos(PI*0/180));
    line(posx+20, posy+15, a, b);

    }
    line(posx+20,posy+15,a,b);
    delay(10);

    if(X0<200)
    {
    //Cabeca
    setcolor(LIGHTBLUE);
    setfillstyle(1,LIGHTBLUE);
    circle(posx, posy, dest);
    floodfill(posx,posy,LIGHTBLUE);

    }


    //Cabeca
    setcolor(YELLOW);
    setfillstyle(1,YELLOW);
    circle(posx, posy, dest);
    floodfill(posx,posy,YELLOW);



    }while (!kbhit());
    tecla=getch();
    cleardevice();
    }while(tecla!=27);

    closegraph();

    }
Exemple #30
0
/******************************************************************************
* Interpret the command line and scan the given GIF file.		      *
******************************************************************************/
void main(int argc, char **argv)
{
    int	i, j, k, Error, NumFiles, Size, Row, Col, Width, Height, ExtCode,
	Count, ColorMapSize, GraphDriver, GraphMode, Sum,
	HelpFlag = FALSE,
	BGIPathFlag = FALSE,
	BGIUserDriverFlag = FALSE,
	ZoomFlag = FALSE;
    GifRecordType RecordType;
    GifByteType *Extension;
    char Str[80], *BGIUserDriverNameMode,
	**FileName = NULL;
    GifRowType *ScreenBuffer;
    GifFileType *GifFile;
    struct text_info TextInfo;      /* So we can restore starting text mode. */

    if ((Error = GAGetArgs(argc, argv, CtrlStr,
		&GifQuitePrint, &BGIPathFlag, &BGIPath,
		&BGIUserDriverFlag, &BGIUserDriverNameMode,
		&ZoomFlag, &ZoomFactor,
		&BeepsDisabled, &HelpFlag,
		&NumFiles, &FileName)) != FALSE ||
		(NumFiles > 1 && !HelpFlag)) {
	if (Error)
	    GAPrintErrMsg(Error);
	else if (NumFiles > 1)
	    GIF_MESSAGE("Error in command line parsing - one GIF file please.");
	GAPrintHowTo(CtrlStr);
	exit(1);
    }

    if (HelpFlag) {
	fprintf(stderr, VersionStr);
	GAPrintHowTo(CtrlStr);
	exit(0);
    }

    if (BGIUserDriverFlag) {
	/* Use the driver supplied by the user! */
        BGIInstallUserDriver(BGIUserDriverNameMode);
        installuserdriver(BGIUserDriverName, detectVGA);
	GraphDriver = BGI_USER_INSTALL;
    }
    else {
        /* Sense type of display we have and attempt to load right driver. */
        detectgraph(&GraphDriver, &GraphMode);
        if (GraphDriver < 0)
	    GIF_EXIT("BGI Auto detect: No graphics device detected.");
    }

    /* Put in the following any graphic driver specific setup: */
    switch (GraphDriver) {
	case CGA:
	    GraphMode = CGAHI;
	    break;
	case EGA:
	    GraphMode = EGAHI;
	    break;
	case EGA64:
	    GraphMode = EGA64HI;
	    break;
	case EGAMONO:
	    GraphMode = EGAMONOHI;
	    break;
	case HERCMONO:
	    GraphMode = HERCMONOHI;
	    break;
	case VGA:
	    GraphMode = VGAHI;
	    break;
	case BGI_USER_INSTALL:
	    GraphDriver = DETECT;
	    GraphMode = BGIUserDriverMode;
	    break;
	default:
	    GIF_EXIT("Requested graphic device is not supported.");
	    break;
    }

    if (NumFiles == 1) {
	GifFileName = *FileName;
	if ((GifFile = DGifOpenFileName(*FileName)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }
    else {
	/* Use the stdin instead: */
	GifFileName = "Stdin";
	setmode(0, O_BINARY);
	if ((GifFile = DGifOpenFileHandle(0)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }

    /* Allocate the screen as vector of column of rows. We cannt allocate    */
    /* the all screen at once, as this broken minded CPU can allocate up to  */
    /* 64k at a time and our image can be bigger than that:		     */
    /* Note this screen is device independent - its the screen as defined by */
    /* the GIF file parameters itself.					     */
    if ((ScreenBuffer = (GifRowType *)
	malloc(GifFile -> SHeight * sizeof(GifRowType *))) == NULL)
	    GIF_EXIT("Failed to allocate memory required, aborted.");

    Size = GifFile -> SWidth * sizeof(GifPixelType);/* Size in bytes of one row.*/
    if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL)    /* First row. */
	GIF_EXIT("Failed to allocate memory required, aborted.");

    for (i = 0; i < GifFile -> SWidth; i++)  /* Set its color to BackGround. */
	ScreenBuffer[0][i] = GifFile -> SBackGroundColor;
    MaximumScreenHeight = GifFile -> SHeight - 1;
    for (i = 1; i < GifFile -> SHeight; i++) {
	/* Allocate the other rows, and set their color to background too: */
	if ((ScreenBuffer[i] = (GifRowType) malloc(Size)) == NULL) {
	    if (i > 30) {
		/* Free some memory for the BGI driver and auxilary. */
		for (j = 1; j < 28; j++)
	    	    free((char *) ScreenBuffer[i - j]);
	    	MaximumScreenHeight = i - 28;
	    	fprintf(stderr, "\n%s: Failed to allocate all memory required, last line %d.\n",
			PROGRAM_NAME, MaximumScreenHeight);
	    	break;
	    }
	    else
		GIF_EXIT("Failed to allocate memory required, aborted.");
	}

	memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);
    }

    /* Scan the content of the GIF file and load the image(s) in: */
    do {
	if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
	    PrintGifError();
	    break;
	}
	switch (RecordType) {
	    case IMAGE_DESC_RECORD_TYPE:
		if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}

		Row = GifFile -> ITop; /* Image Position relative to Screen. */
		Col = GifFile -> ILeft;
		Width = GifFile -> IWidth;
		Height = GifFile -> IHeight;
		GifQprintf("\n%s: Image %d at (%d, %d) [%dx%d]:     ",
		    PROGRAM_NAME, ++ImageNum, Col, Row, Width, Height);
		if (GifFile -> ILeft + GifFile -> IWidth > GifFile -> SWidth ||
		   GifFile -> ITop + GifFile -> IHeight > GifFile -> SHeight) {
		    fprintf(stderr, "Image %d is not confined to screen dimension, aborted.\n");
		    exit(-2);
		}
		if (GifFile -> IInterlace) {
		    /* Need to perform 4 passes on the images: */
		    for (Count = i = 0; i < 4; i++)
			for (j = Row + InterlacedOffset[i]; j < Row + Height;
						 j += InterlacedJumps[i]) {
			    GifQprintf("\b\b\b\b%-4d", Count++);
			    if (DGifGetLine(GifFile,
				&ScreenBuffer[MIN(j, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
				PrintGifError();
				exit(-1);
			    }
			}
		}
		else {
		    for (i = 0; i < Height; i++, Row++) {
			GifQprintf("\b\b\b\b%-4d", i);
			if (DGifGetLine(GifFile, &ScreenBuffer[MIN(Row, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
			    PrintGifError();
			    MaximumScreenHeight = MIN(i - 1, MaximumScreenHeight);
			}
		    }
		}
		break;
	    case EXTENSION_RECORD_TYPE:
		/* Skip any extension blocks in file: */
		if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}
		while (Extension != NULL) {
		    if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
			PrintGifError();
			exit(-1);
		    }
		}
		break;
	    case TERMINATE_RECORD_TYPE:
		break;
	    default:		    /* Should be traps by DGifGetRecordType. */
		break;
	}
    }
    while (RecordType != TERMINATE_RECORD_TYPE);

    /* Lets display it - set the global variables required and do it: */
    BackGround = GifFile -> SBackGroundColor;
    ColorMap = (GifFile -> IColorMap ? GifFile -> IColorMap :
				       GifFile -> SColorMap);
    ColorMapSize = 1 << (GifFile -> IColorMap ? GifFile -> IBitsPerPixel :
						GifFile -> SBitsPerPixel);

    gettextinfo(&TextInfo);	     /* Save current mode so we can recover. */

    initgraph(&GraphDriver, &GraphMode, BGIPath);
    if (graphresult() != grOk)	 	       /* Error occured during init. */
	GIF_EXIT("Graphics System Error, failed to initialize driver.");

    if (getmaxcolor() + 1 < ColorMapSize) {
	sprintf(Str, "GIF Image color map (%d) is too big for device (%d).\n",
					      ColorMapSize, getmaxcolor() + 1);
	closegraph();
	GIF_EXIT(Str);
    }

    /* Initialize hardware pallete and also select fore/background color.    */
    BackGround = ForeGround = 1;
    Sum = ((int) ColorMap[1].Red) +
	  ((int) ColorMap[1].Green) +
	  ((int) ColorMap[1].Blue);
    j = k = Sum;
    for (i = 0; i < ColorMapSize; i++) {
	setrgbpalette(i, ColorMap[i].Red >> 2,
			 ColorMap[i].Green >> 2,
			 ColorMap[i].Blue >> 2);

	Sum = ((int) ColorMap[i].Red) +
	      ((int) ColorMap[i].Green) +
	      ((int) ColorMap[i].Blue);
	if (i != 0 && Sum > j) {			/* Dont use color 0. */
	    ForeGround = i;
	    j = Sum;
	}
	if (i != 0 && Sum <= k) {			/* Dont use color 0. */
	    BackGround = i;
	    k = Sum;
	}
    }

    DeviceMaxX = getmaxx();		    /* Read size of physical screen. */
    DeviceMaxY = getmaxy();
    ScreenWidth = GifFile -> SWidth;
    ScreenHeight = MIN(GifFile -> SHeight, MaximumScreenHeight);

    Tone(500, 10);
    DisplayScreen(ScreenBuffer, GifFile);

    if (DGifCloseFile(GifFile) == GIF_ERROR) {
	PrintGifError();
	closegraph();
	exit(-1);
    }

    closegraph();

    textmode(TextInfo.currmode);
}