📄 newmorning.c
字号:
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();
}
/***************************************************/
/*******************************************************/
/***************************************************/
/*******************************************************/
void DrawHermiteCurve(int x1,int y1,int x2,int y2,int xr1,int yr1,int xr2,int yr2,int color)
{
int i, oldx, oldy, m1, m2, m3, m4, x, y, k1, k2;
oldx = x1;
oldy = y1;
m1 = Iterative3;
m2 = m3 = m4 = 0;
for (i=0; i<Iterative; i++)
{
k1 = (i << 1) + 1;
k2 = (k1+i)*i + k1;
m4 += (k2 -= (k1 *= Iterative));
m3 += (k1 = k2 - k1) + Iterative2;
m2 -= (k2 += k1);
m1 += k2;
x = (int) (((long) x1*m1 + (long) x2*m2 + (long) xr1*m3 +
(long) xr2*m4) / Iterative3);
y = (int) (((long) y1*m1 + (long) y2*m2 + (long) yr1*m3 +
(long) yr2*m4) / Iterative3);
setcolor(color);
line(oldx,oldy,x,y);
oldx = x;
oldy = y;
}
}
void DrawBezierCurve(int x1,int y1,int x2,int y2,int xr1,int yr1,int xr2,int yr2,int color)
{
DrawHermiteCurve(x1,y1,x2,y2,3*(xr1-x1),3*(yr1-y1),3*(x2-xr2),3*(y2-yr2),color); /*braizer。曲线*/
}
hemit()
{
int x1,x2,y1,y2,xr1,xr2,yr1,yr2;
initgr();
/* BGI初始化 */
x1=200;
y1=150;
x2=300;
y2=450;
xr1=100;
yr1=200;
xr2=400 ;
yr2=300;
outtextxy(50,50,"This is hermite curve and Bezier curve!");
DrawHermiteCurve( x1, y1, x2, y2, xr1, yr1, xr2, yr2,2) ;
DrawHermiteCurve(x1,y1,x2,y2,3*(xr1-x1),3*(yr1-y1),3*(x2-xr2),3*(y2-yr2),1);
getch();
jingzhimenu();}
/****************************************************************************/
void DisplayCubicBezierCurve3(Vector P[4],int count)
{
float C[2][4],t,deltat;
Vector V,newV;
int i,j;
for(j=0;j<2;j++)
{
C[j][0]=P[0][j];/*P[0][j]-2*P[1][j]+P[2][j];*/
C[j][1]=-3*P[0][j]+3*P[1][j];
C[j][2]=3*P[0][j]-6*P[1][j]+3*P[2][j];
C[j][3]=-1*P[0][j]+3*P[1][j]-3*P[2][j]+P[3][j];
}
V[X]=C[X][0];V[Y]=C[Y][0];
deltat=1.0/count;
t=0.0;
for(i=1;i<=count;i++)
{
t+=deltat;
newV[X]=C[X][0]+t*C[X][1]+t*t*C[X][2]+t*t*t*C[X][3];
newV[Y]=C[Y][0]+t*C[Y][1]+t*t*C[Y][2]+t*t*t*C[Y][3];
line(V[X],V[Y],newV[X],newV[Y]);
V[X]=newV[X]; V[Y]=newV[Y];
}
}
/****************************************************************/
/****************************************************************/
/*二次Bezier曲线的生成*/
void DisplayCubicBezierCurve2(Vector P[3],int count)
{
float C[2][3],t,deltat;
Vector V,newV;
int i,j;
for(j=0;j<2;j++)
{
C[j][0]=P[0][j];/*P[0][j]-2*P[1][j]+P[2][j];*/
C[j][1]=-2*P[0][j]+2*P[1][j];
C[j][2]=P[0][j]-2*P[1][j]+P[2][j];
}
V[X]=C[X][0];V[Y]=C[Y][0];
deltat=1.0/count;
t=0.0;
for(i=1;i<=count;i++)
{
t+=deltat;
newV[X]=C[X][0]+t*C[X][1]+t*t*C[X][2];
newV[Y]=C[Y][0]+t*C[Y][1]+t*t*C[Y][2];
setcolor(YELLOW);
line(V[X],V[Y],newV[X],newV[Y]);
V[X]=newV[X];V[Y]=newV[Y];
}
}
/****************************************************************/
brzie()
{
int count;
Vector P1[4]={{50,400},{100,200},{300,150},{400,350}};
Vector P2[3]={{50,400},{100,200},{300,150}};
count=1000;
initgr(); /* BGI初始化 */
setcolor(2);
line(50,400,100,200);
getch();
setcolor(5);
line(100,200,300,150);
getch();
setcolor(BLUE);
line(300,150,400,350);
getch();
setcolor(YELLOW);
DisplayCubicBezierCurve3(P1,count);
getch();
DisplayCubicBezierCurve2(P2,count);
getch();
/* 暂停一下,看看前面绘图代码的运行结果 */
jingzhimenu();
}
/***************************************************/
/*******************************************************/
/*填充*/
/***************************************************/
/*******************************************************/
/* WIN-TC BGI 图形编程模板 */
void put_in_sides_list(int entry,int x1,int y1,int x2,int y2,int next_y)
{
int maxy;
float x2_temp,x_change_temp;
x_change_temp=(float)(x2-x1)/(float)(y2-y1);
x2_temp=x2;/*以下为退缩一点操作. */
if((y2>y1)&&(y2>next_y)) /*多边形的上顶点*/
{
y2--;
x2_temp-=x_change_temp;
}
else if((y2<y1)&&(y2<next_y)) /*多边形的下顶点*/
{
y2++;
x2_temp+=x_change_temp;
}
maxy=(y1>y2)?y1:y2;
while((entry>0)&&(maxy>sides[entry-1].y_top)) /*如果所交的顶点是左顶点或右顶点,所有左、右顶点作如下处理*/
{
sides[entry]=sides[entry-1];
entry--;
}
sides[entry].y_top=maxy;
sides[entry].delta_y=abs(y2-y1)+1;
if(y1>y2) sides[entry].x_int=x1;
else {sides[entry].x_int=x2_temp;
sides[entry].x_change_per_scan=x_change_temp;
}
}
void sort_on_bigger_y(int n) /*按照输入的多边形,建立起活性边表*/
{
int k,x1,y1;
side_count=0;
y1=y[n-1];
x1=x[n-1];
bottomscan=y[n-1];
for(k=0;k<n;k++)
{
if(y1!=y[k]) /*判断边是否水平*/
{
side_count++;
put_in_sides_list(side_count,x1,y1,x[k],y[k],y[k+1]); /*非水平边调用put_in_side_list子程序放入活性边来*/
}
else {
line(x1,y1,x[k],y[k]); /*是水平边则直接画出*/
}
if(y[k]<bottomscan)bottomscan=y[k];
y1=y[k];x1=x[k];
}
}
void update_first_and_last(int count2,int scan1) /*刷新活性边表的first和last两根指针的所指位置,以保证指针指出激活边的范围*/
{
while((sides[last_s+1].y_top>=scan1)&&(last_s<count2))last_s++;
while(sides[first_s].delta_y==0)first_s++;
}
void swap(EACH_ENTRY x,EACH_ENTRY y) /*交换活性边表中两条相邻位置边的彼此位置*/
{
int i_temp;
float f_temp;
i_temp=x.y_top;x.y_top=y.y_top;y.y_top=i_temp;
f_temp=x.x_int;x.x_int=y.x_int;y.x_int=f_temp;
i_temp=x.delta_y;x.delta_y=y.delta_y;y.delta_y=i_temp;
f_temp=x.x_change_per_scan;x.x_change_per_scan=y.x_change_per_scan;y.x_change_per_scan=f_temp;
}
void sort_on_x(int entry) /*将一条边side[entry],在活性边表的first到entry之间按x_int的大小插入合适位置*/
{
while((entry>=first_s)&&(sides[entry].x_int<sides[entry-1].x_int))
{
swap(sides[entry],sides[entry-1]); /*调用swap子程序交换两条边的彼此位置*/
entry--;
}
}
void process_x_intersections(int first_s1,int last_s1) /*对活性边表中的激活边按照x_int的大小排序 */
{
int k;
x_int_count=0;
for(k=first_s1;k<last_s1+1;k++)
{
if(sides[k].delta_y>0)
{
x_int_count++;
sort_on_x(k); /*从first到last,对每一根 △y> 0的边,调用sort_on_x子程序排入活性边表中合适位置*/
}
}
}
void draw_lines(int scan3,int x_int_count1,int index) /*在一条扫描线位于多边形内的部分,填上指定的色彩*/
{
int k,x,x1,x2;
for(k=1;k<(int)(x_int_count1/2+1.5);k++)
{
while(sides[index].delta_y==0)index++;
x1=(int)(sides[index].x_int+0.5);index++;
while(sides[index].delta_y==0)index++;
x2=(int)(sides[index].x_int+0.5);/*在活性边表的激活边范围内,依次取出Δy'= 0两边的x_int*/
line(x1,scan3,x2,scan3); /*得到两个端点(x1, scan),(x2, scan),画一条水平线*/
index++;
}
}
void update_sides_list()
{
int k;
for(k=first_s;k<last_s+1;k++)
{
if(sides[k].delta_y>0)
{
sides[k].delta_y--;
sides[k].x_int-=sides[k].x_change_per_scan; /*刷新活性边表内激活边的值:Δy=Dy-1*/
}
}
}
void fill_area(int count1) /*主函数,调用其它8个函数*/
/*所填充多边形的顶点个数*/
{
sort_on_bigger_y(count1);
first_s=0;last_s=0;
for(scan=sides[0].y_top;scan>bottomscan;scan--)
{
update_first_and_last(count1,scan);
process_x_intersections(first_s,last_s);
draw_lines(scan,x_int_count,first_s);
update_sides_list();
}
}
/*下面为递归填充*/
void seedfilling(int x,int y,int fill_color,int boundary_color)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -