#include
#include
#include
#include
#include
int pixels[2][4];
float xn1,xn2,yn1,yn2,x3,y3,m;
void show_quadrant()
{
cleardevice();
rectangle(120,40,320,240);
rectangle(320,40,520,240);
rectangle(120,240,320,440);
rectangle(320,240,520,440);
for(int i=130;i<=510;i+=10) { if(i==320) continue; outtextxy(i,237,"+"); } for(i=50;i<=430;i+=10) { if(i==240) continue; outtextxy(317,i,"-"); } outtextxy(310,230,"O"); outtextxy(530,240,"X"); outtextxy(320,450,"-Y"); outtextxy(100,240,"-X"); outtextxy(320,30,"Y"); } void midpt(int x1,int y1,int x2,int y2,int xmin,int ymin,int xmax,int ymax) { int fl=1; int pixels[2][4],i,j; for(i=0;i<2;i++) for(j=0;j<4;j++) pixels[i][j]=0; if(y1>ymax)
pixels[0][0]=1;
if(y1
pixels[0][2]=1;
if(x1
pixels[1][0]=1;
if(y2
pixels[1][2]=1;
if(x2
{
gotoxy(xx,1);
cout<
cout<<" " Enter X(max) & Y(max) ":="; cin>>xmax>>ymax;
cout<<" " Enter The No Of Vertices Of Polygon ":="; cin>>ver;
for(i=0;i
}
x[ver]=x[0];
y[ver]=y[0];
clrscr();
initgraph(&gd,&gm,"..\bgi");
clearviewport();
show_quadrant();
line(320+xmin,240-ymin,320+xmin,240-ymax);
line(320+xmin,240-ymax,320+xmax,240-ymax);
line(320+xmax,240-ymax,320+xmax,240-ymin);
line(320+xmax,240-ymin,320+xmin,240-ymin);
for(i=0;i
getch();
cleardevice();
show_quadrant();
line(320+xmin,240-ymin,320+xmin,240-ymax);
line(320+xmin,240-ymax,320+xmax,240-ymax);
line(320+xmax,240-ymax,320+xmax,240-ymin);
line(320+xmax,240-ymin,320+xmin,240-ymin);
for(i=0;i
midpt(x[i],y[i],x[i+1],y[i+1],xmin,ymin,xmax,ymax);
}
getch();
closegraph();
}
No comments:
Post a Comment