コード例 #1
0
ファイル: 3-67.c プロジェクト: Huericiz/C_lg_small_examples
drawhair()
{
   int x,y,r;
   setcolor(8);
   setaspectratio(xasp,yasp/1.5);
   r=face1->radius;
   x=face1->position.x-r/2;
   y=face1->position.y-r/3;

   arc(x,y,34,225,100);

   arc(x+r,y,314,138,100);

   setfillstyle(1,RED);
   floodfill(x,y-70,getcolor());
   floodfill(x+r,y-70,getcolor());
   setaspectratio(xasp,yasp);
}
コード例 #2
0
ファイル: 3-67.c プロジェクト: Huericiz/C_lg_small_examples
draweyes()
{
   int i,x1,x2,y1,y2,r;
   setcolor(0);
   r=face1->radius;
   x1=face1->position.x-r/2;
   y1=face1->position.y-r/4;
   x2=face1->position.x+r/2;
   y2=face1->position.y-r/4;

   setaspectratio(xasp/2,yasp);
   arc(x1,y1-r/8,40,140,r/4);
   arc(x1,y1-r/8+1,40,140,r/4);
   arc(x1,y1-r/8+2,40,140,r/4);
   setaspectratio(xasp,yasp);

   for(i=0;i<2;i++)
   {
     arc(x1,y1+i+5,40,140,r/4);
     arc(x1,y1-r/5+i,220,320,r/4);
   }
   circle(x1,y1-r/12,r/10);
   setfillstyle(1,0);
   floodfill(x1,y1-r/10,getcolor());
   setfillstyle(1,WHITE);
   floodfill(x1-15,y1-r/6,getcolor());

   setaspectratio(xasp/2,yasp);
   arc(x2,y2-r/8,40,140,r/4);
   arc(x2,y2-r/8+1,40,140,r/4);
   arc(x2,y2-r/8+2,40,140,r/4);
   setaspectratio(xasp,yasp);

   for(i=0;i<2;i++)
   {
     arc(x2,y2+i+5,40,140,r/4);
     arc(x2,y2-r/5+i,220,320,r/4);
   }
   circle(x2,y2-r/12,r/10);
   setfillstyle(1,0);
   floodfill(x2,y2-r/12,getcolor());
   setfillstyle(1,WHITE);
   floodfill(x2-15,y2-r/6,getcolor());
}
コード例 #3
0
ファイル: lab3_pie.c プロジェクト: techgaun/graphics_lab
int main()
{
	struct pie_data data[MAX];
	int gd = DETECT, gm;
	int i, j, k, n, total_freq = 0, start_angle = 0, end_angle = 0, xmax, ystart = 80, yend;
	printf("Enter the number of items: ");
	scanf("%d", &n);
	
	for (i = 0, j = 1, k = 1; i < n; i++)
	{
		printf("Enter the item title: ");
		scanf("%s", data[i].desc);
		printf("Enter the item frequency: ");
		scanf("%d", &data[i].freq);
		total_freq += data[i].freq;
		data[i].color = j;
		data[i].style = k;
		if (j++ >= 13) j = 1;
		if (k++ >= 11) k = 1;
	}
	
	for (i = 0; i < n; i++)
	{
		float angle;
		data[i].angle = 360 * (data[i].freq /(float) total_freq);
	}
	
	initgraph(&gd, &gm, "C:\\TurboC3\\BGI");
	xmax = getmaxx() - 150;
	setaspectratio(10000, 10000);
	for (i = 0; i < n; i++)
	{
		end_angle = start_angle + data[i].angle;
		setcolor(data[i].color);
		setfillstyle(data[i].style, data[i].color);
		pieslice(X_CENTRE, Y_CENTRE, (int)start_angle, (int)end_angle, RADIUS);
		start_angle = end_angle;
		yend = ystart + 40;
		bar(xmax, ystart, xmax + 70, yend);
		ystart = yend + 15;
		outtextxy(xmax + 80, ystart - 20, data[i].desc);
	}
	getch();
	closegraph();
	return 0;
}
コード例 #4
0
ファイル: P372.CPP プロジェクト: agudeloandres/C_Struct_Files
int main() {
	int unidad = 0,modo,k,x,y,tx,ty;
	char s[10],s1[10],*titulo;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setcolor (YELLOW);
	getaspectratio (&x,&y);
	tx = x;
	ty = y;
	itoa (x,s,10);
	itoa (y,s1,10);
	k = strlen (s) + strlen (" ") + strlen (s1) + 1;
	titulo = new char [k];
	strcpy (titulo,s);
	strcat (titulo," ");
	strcat (titulo,s1);
	outtextxy (0,10,titulo);
	delete titulo;
	gcvt ( (double)y / x,5,s);
	outtextxy (200,10,s);
	circle (200,200,100);

	setcolor (WHITE);
	setaspectratio (tx / 2,ty);
	getaspectratio (&x,&y);
	itoa (x,s,10);
	itoa (y,s1,10);
	k = strlen (s) + strlen (" ") + strlen (s1) + 1;
	titulo = new char [k];
	strcpy (titulo,s);
	strcat (titulo," ");
	strcat (titulo,s1);
	outtextxy (0,20,titulo);
	delete titulo;
	gcvt ( (double)y / x,5,s);
	outtextxy (200,20,s);
	circle (200,200,100);

	setcolor (RED);
	setaspectratio (tx,ty / 2);
	getaspectratio (&x,&y);
	
	itoa (x,s,10);
	itoa (y,s1,10);
	k = strlen (s) + strlen (" ") + strlen (s1) + 1;
	titulo = new char [k];
	strcpy (titulo,s);
	strcat (titulo," ");
	strcat (titulo,s1);
	outtextxy (0,30,titulo);
	delete titulo;
	gcvt ( (double)y / x,5,s);
	outtextxy (200,30,s);
	circle (200,200,100);
	getch();
	closegraph();
	return 0;
}