⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newmorning.c

📁 计算机图形学
💻 C
📖 第 1 页 / 共 4 页
字号:
 poly[18]=poly[0]-30;poly[19]=poly[5];
 poly[20]=poly[0];poly[21]=poly[1];     /*画五角星的各个顶点*/
 drawpoly(11,poly);
 seedfilling(310,330,RED,15);  /*填充五角星*/

 circle(230,140,35);
 seedfilling(230,140,YELLOW,15);
 circle(230,140,20);
 seedfilling(230,140,GREEN,15);
 circle(230,140,5);
 seedfilling(230,140,WHITE,15);   /*填充头像的左眼睛*/

 circle(410,140,35);
 seedfilling(410,140,YELLOW,15);
 circle(410,140,20);
 seedfilling(410,140,GREEN,15);
 circle(410,140,5);
 seedfilling(410,140,WHITE,15); /*填充头像的右眼睛*/

 ellipse(325,225,0,360,36,46);
 seedfilling(325,225,GREEN,15); /*填充头像的鼻子*/


 /*下面为线型算法*/
 LineDDA(12,18,130,250,WHITE);
 LineDDA(472,18,590,250,WHITE);
 LineDDA(222,18,370,250,WHITE);
  LineDDA(272,238,420,470,WHITE);
 /*下面为图形填充*/
/*circle(540,400,40);
picturefilling(540,400,540,400,RED,15);
  circle(100,320,40);
picturefilling(100,320,100,320,RED,15);*/
 /*下面为扫描线填充*/


  getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
    /* 恢复TEXT屏幕模式 */

jingzhimenu();

}

/***************************************************/
/*******************************************************/




/*3. 字符输出呵呵 */
/********************************************************************/
/***********************************************************************/
void heng1(int hx,int hy)
{
 setcolor(YELLOW);
 line(hx+6,hy+0,hx+30,hy+0);

 line(hx+6,hy+1,hx+30,hy+1);
setcolor(WHITE);
 line(hx+5,hy+2,hx+31,hy+2);
 setcolor(YELLOW);
  line(hx+6,hy+3,hx+30,hy+3);
 line(hx+6,hy+4,hx+30,hy+4);
}
void shu1(int sx,int sy)
{
 setcolor(YELLOW);
 line(sx+0,sy+5,sx+0,sy+30);
 line(sx+1,sy+5,sx+1,sy+30);
 setcolor(WHITE);
 line(sx+2,sy+4,sx+2,sy+31);
 setcolor(YELLOW);
 line(sx+3,sy+5,sx+3,sy+30);
 line(sx+4,sy+5,sx+4,sy+30);
}
void draw_01(int x0,int y0)
{
 heng1(x0,y0);

 heng1(x0,y0+60);

 shu1 (x0,y0);
 shu1 (x0+32,y0);
 shu1 (x0+32,y0+30);
 shu1 (x0,y0+30);
}
void draw_11(int x0,int y0)
{
shu1 (x0+32,y0);
shu1 (x0+32,y0+30);

}
void draw_2(int x0,int y0)
{
 heng1(x0,y0);
 heng1(x0,y0+30);
 heng1(x0,y0+60);
 shu1 (x0+32,y0);
 shu1 (x0,y0+30);
}
void draw_31(int x0,int y0)
{
 heng1(x0,y0);
 heng1(x0,y0+30);
 heng1(x0,y0+60);


 shu1 (x0+32,y0);
 shu1 (x0+32,y0+30);

}
void draw_4(int x0,int y0)
{

 heng1(x0,y0+30);


 shu1 (x0,y0);
 shu1 (x0+32,y0);
 shu1 (x0+32,y0+30);

}
void draw_5(int x0,int y0)
{
 heng1(x0,y0);
 heng1(x0,y0+30);
 heng1(x0,y0+60);

 shu1 (x0,y0);

 shu1 (x0+32,y0+30);

}
void draw_point(px,py)
{
 register int i,j;
 for(i=0;i<5;i++)
  for(j=0;j<5;j++)
  if(!((i==1)&&(j==1)))
  putpixel(px+j,py+i,YELLOW);
 putpixel(px+1,py+1,WHITE);
}




char tu64H[]={
/* 以下是 '图' 的 64点阵黑体 字模,512 byte */
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x20,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x3C,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x3C,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x7C,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0xF8,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0xFF,0xFF,0xF8,0x0F,0x00,
  0x01,0xF0,0x01,0xFF,0xFF,0xF0,0x0F,0x00,
  0x01,0xF0,0x03,0xFF,0xFF,0xE0,0x0F,0x00,
  0x01,0xF0,0x03,0xC0,0x01,0xE0,0x0F,0x00,
  0x01,0xF0,0x07,0xC0,0x03,0xC0,0x0F,0x00,
  0x01,0xF0,0x0F,0xC0,0x03,0xC0,0x0F,0x00,
  0x01,0xF0,0x1F,0xE0,0x07,0x80,0x0F,0x00,
  0x01,0xF0,0x3E,0xF0,0x0F,0x00,0x0F,0x00,
  0x01,0xF0,0x7C,0x78,0x1E,0x00,0x0F,0x00,
  0x01,0xF0,0x78,0x3C,0x3C,0x00,0x0F,0x00,
  0x01,0xF0,0x30,0x1F,0x78,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x07,0xF0,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x3F,0xFC,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0xFE,0x7F,0x80,0x0F,0x00,
  0x01,0xF0,0x03,0xF8,0x1F,0xF0,0x0F,0x00,
  0x01,0xF0,0x3F,0xE0,0x07,0xFF,0x0F,0x00,
  0x01,0xF1,0xFF,0x80,0x01,0xFF,0x0F,0x00,
  0x01,0xF0,0xFE,0x06,0x00,0x3F,0x0F,0x00,
  0x01,0xF0,0x70,0x0F,0x80,0x0E,0x0F,0x00,
  0x01,0xF0,0x00,0x0F,0xF0,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x07,0xFE,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0xFE,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x3C,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x0C,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0xF8,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0xFF,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x01,0xFF,0xE0,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x3F,0xFC,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x07,0xFF,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0xFE,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x1C,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x04,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x00,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x00,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
  0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x80,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x80,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x0F,0x80,
  0x01,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char xing64H[]={
/* 以下是 '形' 的 64点阵黑体 字模,512 byte */
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,
  0x03,0xFF,0xFF,0xFF,0xF0,0x00,0x3F,0x00,
  0x03,0xFF,0xFF,0xFF,0xF0,0x00,0x7E,0x00,
  0x03,0xFF,0xFF,0xFF,0xF0,0x00,0x7C,0x00,
  0x02,0x07,0x80,0x78,0x10,0x00,0xF8,0x00,
  0x00,0x07,0x80,0x78,0x00,0x01,0xF0,0x00,
  0x00,0x07,0x80,0x78,0x00,0x03,0xE0,0x00,
  0x00,0x07,0x80,0x78,0x00,0x03,0xC0,0x00,
  0x00,0x07,0x80,0x78,0x00,0x07,0xC0,0x00,
  0x00,0x07,0x80,0x78,0x00,0x0F,0x80,0x00,
  0x00,0x07,0x80,0x78,0x00,0x1F,0x00,0x00,
  0x00,0x07,0x80,0x78,0x00,0x3E,0x00,0x00,
  0x00,0x07,0x80,0x78,0x00,0x7C,0x00,0x00,
  0x00,0x07,0x80,0x78,0x00,0xF8,0x00,0x00,
  0x00,0x07,0x80,0x78,0x01,0xF0,0x00,0x00,
  0x00,0x07,0x80,0x78,0x07,0xF0,0x00,0x00,
  0x00,0x07,0x80,0x78,0x03,0xE0,0x04,0x00,
  0x00,0x07,0x80,0x78,0x00,0xC0,0x06,0x00,
  0x00,0x07,0x80,0x78,0x00,0x00,0x0F,0x80,
  0x00,0x07,0x80,0x78,0x00,0x00,0x1F,0xC0,
  0x00,0x07,0x80,0x78,0x00,0x00,0x3F,0x00,
  0x00,0x07,0x80,0x78,0x00,0x00,0x7E,0x00,
  0x07,0xFF,0xFF,0xFF,0xF8,0x00,0xFC,0x00,
  0x07,0xFF,0xFF,0xFF,0xF8,0x00,0xF8,0x00,
  0x07,0xFF,0xFF,0xFF,0xF8,0x01,0xF0,0x00,
  0x04,0x0F,0x00,0x78,0x08,0x03,0xE0,0x00,
  0x00,0x0F,0x00,0x78,0x00,0x07,0xC0,0x00,
  0x00,0x0F,0x00,0x78,0x00,0x1F,0x80,0x00,
  0x00,0x0F,0x00,0x78,0x00,0x3F,0x00,0x00,
  0x00,0x0F,0x00,0x78,0x00,0x7E,0x00,0x00,
  0x00,0x0F,0x00,0x78,0x01,0xFC,0x00,0x00,
  0x00,0x0F,0x00,0x78,0x03,0xF8,0x00,0x00,
  0x00,0x0F,0x00,0x78,0x0F,0xE0,0x00,0x00,
  0x00,0x0F,0x00,0x78,0x07,0xC0,0x01,0x80,
  0x00,0x0E,0x00,0x78,0x03,0x80,0x03,0xC0,
  0x00,0x1E,0x00,0x78,0x01,0x00,0x07,0xF0,
  0x00,0x1E,0x00,0x78,0x00,0x00,0x0F,0xE0,
  0x00,0x1E,0x00,0x78,0x00,0x00,0x1F,0xC0,
  0x00,0x1E,0x00,0x78,0x00,0x00,0x3F,0x00,
  0x00,0x3C,0x00,0x78,0x00,0x00,0x7E,0x00,
  0x00,0x3C,0x00,0x78,0x00,0x00,0xFC,0x00,
  0x00,0x3C,0x00,0x78,0x00,0x03,0xF8,0x00,
  0x00,0x78,0x00,0x78,0x00,0x07,0xE0,0x00,
  0x00,0x78,0x00,0x78,0x00,0x0F,0xC0,0x00,
  0x00,0xF8,0x00,0x78,0x00,0x3F,0x80,0x00,
  0x00,0xF0,0x00,0x78,0x00,0x7F,0x00,0x00,
  0x01,0xF0,0x00,0x78,0x01,0xFC,0x00,0x00,
  0x03,0xE0,0x00,0x78,0x07,0xF8,0x00,0x00,
  0x07,0xC0,0x00,0x78,0x1F,0xF0,0x00,0x00,
  0x07,0xC0,0x00,0x78,0x1F,0xC0,0x00,0x00,
  0x07,0x80,0x00,0x78,0x0F,0x80,0x00,0x00,
  0x01,0x80,0x00,0x00,0x06,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
char xue64H[]={
/* 以下是 '学' 的 64点阵黑体 字模,512 byte */
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,
  0x00,0x00,0x80,0x07,0x80,0x03,0x80,0x00,
  0x00,0x03,0x80,0x07,0x80,0x03,0xE0,0x00,
  0x00,0x07,0xC0,0x07,0xC0,0x07,0xE0,0x00,
  0x00,0x03,0xE0,0x07,0xC0,0x07,0xC0,0x00,
  0x00,0x03,0xE0,0x03,0xC0,0x0F,0x80,0x00,
  0x00,0x01,0xF0,0x03,0xC0,0x0F,0x00,0x00,
  0x00,0x01,0xF0,0x03,0xE0,0x1F,0x00,0x00,
  0x00,0x00,0xF8,0x03,0x80,0x1E,0x00,0x00,
  0x00,0x00,0xF0,0x00,0x00,0x3C,0x00,0x00,
  0x00,0x00,0x80,0x00,0x00,0x3C,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,
  0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x03,0xC0,0x00,0x00,0x00,0x00,0x03,0xC0,
  0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,
  0x00,0x00,0x00,0x00,0x07,0xF8,0x00,0x00,
  0x00,0x00,0x00,0x00,0x1F,0xE0,0x00,0x00,
  0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xF0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x06,0x00,0x00,0x01,0xE0,0x00,0x00,0x60,
  0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,
  0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,
  0x07,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x01,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0xFF,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x7F,0xE0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,
  0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

/*字符*/
zifu()
{
int x=12,y=25,i=0,j=0,d;
int r[16]={0xfc,0x66,0x66,0x7c,
           0x60,0x60,0xf0,0x00,
           0xfc,0x66,0x66,0x7c,
           0x66,0x66,0xfc,0x00};
initgr();
draw_point(400,160);
setbkcolor(BLUE);
draw_2(200,100);
draw_11(150,100);
draw_31(250,100);
draw_4(300,100);
draw_5(350,100);
draw_01(100,100);
drawmat(tu64H,64,200,250,RED);
drawmat(xing64H,64,300,250,RED);
drawmat(xue64H,64,400,250,RED);
while(1)
     {
       d=pow(2,7-j);
       if((r[i]&d)==d)
       circle((x+j)*10+5,(y+i)*10+5,5);
       j++;
       if(j>7)
          {
            j=0;
            i++;
            if(i>7)
            break;
          }
      }
/**/
getch();
jingzhimenu();
}
/***************************************************/
/*******************************************************/


/***************************************************/
/*******************************************************/

/*4. 裁剪*/
/***********************************************************/
/***********************************************************/

/*求交点,裁剪中的*/
/*画多边形*/
/***********************************************************************/
/**************************************************************************/
void duobianxing(int n,Vertex a[])
{int i=1;
DDAline(a[n-1].x,a[n-1].y,a[0].x,a[0].y);
for(i=0;i<n-1;i++)
DDAline(a[i].x,a[i].y,a[i+1].x,a[i+1].y);
}


DDAline1()
{
initgr();
midpointline(50,100,250,250,4);
midpointline(300,50,80,250,4);
getch();
jingzhimenu();
}
/*************************************/
 void Intersect(Vertex *s,Vertex *p,Edge clipBoundary,Vertex *I)
{
if(clipBoundary[0].y==clipBoundary[1].y)/*水平的裁剪边*/
{
I->y=clipBoundary[0].y;
I->x=s->x+(clipBoundary[0].y-s->y)*(p->x-s->x)/(p->y-s->y);
}
else/*竖直裁剪边*/
{
I->x=clipBoundary[0].x;
I->y=s->y+(clipBoundary[0].x-s->x)*(p->y-s->y)/(p->x-s->x);
}
}
int Inside(Vertex *testVertex,Edge clipBoundary)
{
if(clipBoundary[1].x>clipBoundary[0].x)
{ if(testVertex->y<=clipBoundary[0].y) return true;
}
else if(clipBoundary[1].x<clipBoundary[0].x)
{ if(testVertex->y>=clipBoundary[0].y) return true;
}
else if(clipBoundary[1].y>clipBoundary[0].y)
{ if(testVertex->x>=clipBoundary[0].x) return true;
}
else if(clipBoundary[1].y<clipBoundary[0].y)
{ if(testVertex->x<=clipBoundary[0].x) return true;
}
return false;
}  /*程序Inside()结束*/

void Output(Vertex *newVertex,int *outLength,VertexArray outVertexArray)
/*将new Vetex加入到结果多边形顶点表outVertexArray中*/
{
outVertexArray[*outLength].x=newVertex->x;
outVertexArray[*outLength].y=newVertex->y;
(*outLength)++;
}/*output结束*/
/* 裁剪算法*/
void SutherlandHodgmanPolygonclip(int inLength,VertexArray inVertexArray,int *outLength,VertexArray outVertexArray,Edge clipBoundary)
{
Vertex *s,*p,I;
int j;
*outLength=0;
s=&(inVertexArray[inLength-1]);
for(j=0;j<inLength;j++)
{
p=&(inVertexArray[j]);
if(Inside(p,clipBoundary))
{ if(Inside(s,clipBoundary))
     Output(p,outLength,outVertexArray);
     else
     { Intersect(s,p,clipBoundary,&I);
     Output(&I,outLength,outVertexArray);
     Output(p,outLength,outVertexArray);
     }
}
else if(Inside(s,clipBoundary))
{ Intersect(s,p,clipBoundary,&I);
Output(&I,outLength,outVertexArray);
}
s=p;
}
}
/* 裁剪开始*/
caijian()
{int i,j,d,inlength,*outLength;
  VertexArray a;
  VertexArray inVertexArray,outVertexArray;
    Edge b1,b2,b3,b4,c;
initgr();
 inlength=7;
inVertexArray[0].x=220;
inVertexArray[0].y=170;
inVertexArray[1].x=290;
inVertexArray[1].y=80;
inVertexArray[2].x=380;
inVertexArray[2].y=130;
inVertexArray[3].x=240;
inVertexArray[3].y=230;
inVertexArray[4].x=430;
inVertexArray[4].y=280;
inVertexArray[5].x=430;
inVertexArray[5].y=50;
inVertexArray[6].x=220;
inVertexArray[6].y=50;
duobianxing(inlength,inVertexArray);
setcolor(1);
rectangle(100,100,300,300);
getch();
cleardevice();
b1[0].x=100;b1[0].y=100;
b1[1].x=100;b1[1].y=300;
b2[0].x=100;b2[0].y=300;
b2[1].x=300;b2[1].y=300;
b3[0].x=300;b3[0].y=300;
b3[1].x=300;b3[1].y=100;
b4[0].x=300;b4[0].y=100;
b4[1].x=100;b4[1].y=100;
SutherlandHodgmanPolygonclip(inlength,inVertexArray,outLength,outVertexArray,b1);
inlength=*outLength;
for(i=0;i<inlength;i++)
inVertexArray[i]=outVertexArray[i];
SutherlandHodgmanPolygonclip(inlength,inVertexArray,outLength,outVertexArray,b2);
inlength=*outLength;
for(i=0;i<inlength;i++)
inVertexArray[i]=outVertexArray[i];
SutherlandHodgmanPolygonclip(inlength,inVertexArray,outLength,outVertexArray,b3);
inlength=*outLength;
for(i=0;i<inlength;i++)
inVertexArray[i]=outVertexArray[i];
SutherlandHodgmanPolygonclip(inlength,inVertexArray,outLength,outVertexArray,b4);
initgr();
duobianxing(*outLength,outVertexArray);
getch();
jingzhimenu();
}

/*******************************************************************/

/*5. 旋转和投影*/
/***************************************************************/
/****************************************************************/
void setidentity( struct matrix *m)
 { int i,j;
   for (i=0;i<3;i++)
     for (j=0;j<3;j++)
     m->h[i][j]=(i==j);    
 }
 void show(struct matrix *m)
{ int i,j;
   for (i=0;i<3;i++)
      { printf("\n");        
      for(j=0;j<3;j++)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -