Page 144 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 144
Lab on Computer Graphics
Notes {
Identity(Matrix);
Xdis=0–poly[0][0];
Ydis=0–poly[0][1];
Translate_to_Relative(poly,points,Xdis,Ydis);
goto Menu;
}
closegraph();
}
void intgraph()
{
int g=DETECT,d;
initgraph(&g,&d,"c:tcbgi");
}
void fill_poly(int poly1[][2],int points,char line_color,char fill_color)
{
int pol[20],i;
char str[2];
for(i=0;i<=points;i++)
{
pol[i*2]=poly1[i][0];
pol[i*2+1]=poly1[i][1];
}
pol[i*2]=poly1[0][0];
pol[i*2+1]=poly1[0][1];
setcolor(line_color);
setfillstyle(8,fill_color);
fillpoly(points+1,pol);
setcolor(fill_color);
settextstyle(1,0,3);
for(i=0;i<=points;i++)
{
sprintf(str,"%c",i+ ‘a’);
outtextxy(poly1[i][0],poly1[i][1],str);
}
}
void Identity(float Matrix[3][3])
{
int i,j;
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
138 LOVELY PROFESSIONAL UNIVERSITY