求个C语言图形程序

来源:百度知道 编辑:UC知道 时间:2024/05/30 10:45:55
有序边裁剪
多边形裁剪
不用输入数据的
好的+分

多边形裁剪:

#include"graphics.h"
#define LEFT 1
#define RIGHT 2
#define BOTTOM 4
#define TOP 8
#define XL 100.0
#define XR 200.0
#define YB 100.0
#define YT 200.0
encode(float x,float y,int *code)
{
int c;
c=0;
if(x<XL) c+=LEFT;
else if(x>XR) c+=RIGHT;
if(y<YB) c+=BOTTOM;
else if(y>YT) c+=TOP;
*code=c;
return;
}
main()
{
int drive,mode;
int color,i,j,k,m;
int code,code1,code2;
float sx,sy,px,py;
float fx,fy,x,y;
float bx[20],by[20];
float pointx[5]={60.0,130.0,150.0,260.0,180.0};
float pointy[5]={150.0,80.0,140.0,160.0,240.0};
printf("\nColor=\n");
scanf("%d",&color);
detectgraph(&drive,&mode);
initgraph(&drive,&mode,"c:\\");
setcolor(3);
line(XL,YB,XL,YT);
line(XL,YB,XR,YB);
line(XL,YT,XR,YT);
line