📄 newmorning.c
字号:
#include<conio.h>
#include<stdlib.h>
#include "stdio.h"
#include "graphics.h"
#include "math.h"
#include"dos.h"
#define closegr closegraph
/*下面为扫描线填充*/
#define MAXPOINT 5
/***********************/
#define max 100
#define true 1
#define error 0
#define false 0
/*#define ORG_X 320 *//*定义原点坐标*/
/*#define ORG_Y 240*/
/*************************/
#define Iterative 24
#define Iterative2 (Iterative*Iterative)
#define Iterative3 (Iterative2*Iterative)
#define X 0
#define Y 1
typedef float Vector[2];
/*************************/
/*#define PATTERN_A 0
#define PATTERN_B 1
#define PATTERN_SOLID -1*/
typedef float vector[2];
typedef struct{
int x,y;
}Vertex;
typedef Vertex Edge[2];
typedef Vertex VertexArray[max];
/**************************************************************/
typedef struct{
int y_top;
float x_int;
int delta_y;
float x_change_per_scan;
}EACH_ENTRY;
EACH_ENTRY sides[MAXPOINT];
int x[MAXPOINT],y[MAXPOINT];
int first_s,last_s,scan,bottomscan,x_int_count,side_count;
int pattern[9][7]={1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,1,1,0,0,0,0,1,
1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0}; /* 定义字符掩膜的矩阵*/
/**********************************************************************/
/******************************************************************/
struct matrix{ float h[3][3]; };
struct wc{ float x,y; };
struct matrix *thematrix;
float radius(float a)
{ return a*3.14/180;}
/***************************************************************/
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
/*界面函数*/
/******************************************************/
/*************************************************************/
void drawmat(char *mat,int matsize,int x,int y,int color)
/*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/
{
int i, j, k, n;
n = (matsize - 1) / 8 + 1;
for(j = 0; j < matsize; j++)
for(i = 0; i < n; i++)
for(k = 0;k < 8; k++)
if(mat[j * n + i] & (0x80 >> k)) /*测试为1的位则显示*/
putpixel(x + i * 8 + k, y + j, color);
}
/*heng*/
void heng(int hx,int hy)
{
setcolor(YELLOW);
line(hx+4,hy+0,hx+11,hy+0);
setcolor(WHITE);
line(hx+3,hy+1,hx+12,hy+1);
setcolor(YELLOW);
line(hx+4,hy+2,hx+11,hy+2);
}
/*shu*/
void shu(int sx,int sy)
{
setcolor(YELLOW);
line(sx+0,sy+3,sx+0,sy+10);
setcolor(WHITE);
line(sx+1,sy+2,sx+1,sy+11);
setcolor(YELLOW);
line(sx+2,sy+3,sx+2,sy+10);
}
/*############--画0函数--##############*/
void draw_0(int x0,int y0)
{
heng(x0,y0);
heng(x0,y0+20);
shu (x0,y0);
shu (x0+13,y0);
shu (x0+13,y0+10);
shu (x0,y0+10);
}
/*############--画1函数--##############*/
void draw_1(int x0,int y0)
{
shu (x0+13,y0);
shu (x0+13,y0+10);
}
/*############--画3函数--##############*/
void draw_3(int x0,int y0)
{
heng(x0,y0);
heng(x0,y0+10);
heng(x0,y0+20);
shu (x0+13,y0);
shu (x0+13,y0+10);
}
char ke48L[]={
/* 以下是 '科' 的 48点阵隶书 字模,288 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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,
0x00,0x00,0xF8,0x00,0x78,0x00,0x03,0x1F,
0xF0,0x00,0x78,0x00,0x00,0xFF,0x80,0x00,
0x78,0x00,0x00,0x07,0x80,0x70,0x38,0x00,
0x00,0x07,0x80,0x3C,0x38,0x00,0x00,0x07,
0x80,0x1E,0x38,0x00,0x03,0x87,0xF8,0x00,
0x38,0x00,0x07,0xFF,0xFC,0x00,0x38,0x00,
0x0F,0xE7,0x80,0x00,0x38,0x00,0x00,0x07,
0x81,0xC0,0x38,0x00,0x00,0x07,0x81,0xFC,
0x38,0x00,0x00,0x0F,0x80,0x00,0x78,0x00,
0x00,0x1F,0xE0,0x00,0x78,0x00,0x00,0x3F,
0xF0,0x00,0x78,0x00,0x00,0x77,0x88,0x00,
0x78,0x00,0x00,0xE7,0x81,0xFF,0xFF,0xFC,
0x01,0xC7,0x81,0xFF,0xFF,0xF8,0x07,0x87,
0x83,0x80,0x78,0x70,0x0F,0x07,0x80,0x00,
0x78,0x00,0x3E,0x07,0x80,0x00,0x38,0x00,
0x78,0x07,0x80,0x00,0x38,0x00,0x00,0x07,
0x80,0x00,0x38,0x00,0x00,0x07,0x80,0x00,
0x38,0x00,0x00,0x07,0x80,0x00,0x38,0x00,
0x00,0x07,0x80,0x00,0x38,0x00,0x00,0x07,
0x80,0x00,0x78,0x00,0x00,0x07,0x80,0x00,
0x78,0x00,0x00,0x07,0x00,0x00,0x30,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,
};
char xin48L[]={
/* 以下是 '信' 的 48点阵隶书 字模,288 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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,
0x00,0x00,0x80,0xF0,0x00,0x00,0x00,0x01,
0x00,0xFC,0x00,0x00,0x00,0x07,0x00,0x7F,
0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,
0x00,0x3C,0x00,0x00,0x00,0x00,0x01,0xF8,
0x20,0xFF,0x80,0x00,0x07,0xF8,0x7F,0xFF,
0xFF,0xFC,0x3F,0xF8,0xFF,0x83,0xFF,0xFC,
0x3F,0xF9,0xE0,0x00,0x0F,0xF8,0x1F,0xF8,
0x00,0x00,0x00,0xF0,0x06,0x78,0x03,0xFF,
0xE0,0x00,0x00,0x78,0x03,0x80,0x00,0x00,
0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x78,
0x00,0x00,0x00,0x00,0x00,0x78,0x07,0xFF,
0xF8,0x00,0x00,0x78,0x06,0x00,0x00,0x00,
0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x78,
0x00,0x00,0x00,0x00,0x00,0x78,0x0F,0xFE,
0x00,0x00,0x00,0x78,0x1F,0xFF,0xFC,0x00,
0x00,0x78,0x1E,0x00,0x7C,0x00,0x00,0x78,
0x1C,0x00,0x3C,0x00,0x00,0x78,0x1C,0x00,
0x3C,0x00,0x00,0x78,0x1E,0x00,0x3C,0x00,
0x00,0x78,0x1F,0xFF,0xFC,0x00,0x00,0x78,
0x0F,0xFF,0xF8,0x00,0x00,0x70,0x0F,0x00,
0xF8,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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
/*void drawmat(char *mat,int matsize,int x,int y,int color)
/*依次:字模指针、点阵大小、起始坐标(x,y)、颜色*/
{
int i, j, k, n;
n = (matsize - 1) / 8 + 1;
for(j = 0; j < matsize; j++)
for(i = 0; i < n; i++)
for(k = 0;k < 8; k++)
if(mat[j * n + i] & (0x80 >> k)) /*测试为1的位则显示*/
putpixel(x + i * 8 + k, y + j, color);
} */
box(int a,int b,int c,int d,int color)
{
setcolor(color);
line(a,b,a,d);
line(a,b,c,b);
line(a,d,c,d);
line(c,b,c,d);
}
/*菜单函数*/
void menu()
{
int i,j;
char c;
initgr();
setbkcolor(1);
drawmat(xin48L,48,20,150,YELLOW);
drawmat(ke48L,48,60,150,YELLOW);
draw_0(26,200);
draw_3(46,200);
draw_0(66,200);
draw_1(82,200);
for(i=130;i<=500;i++)
{for(j=0;j<=100;j++)
delay(10);
setcolor(WHITE);
line(130,20,i,20);
delay(10);
line(128,18,i+2,18);
}
for(i=20;i<=460;i++)
{for(j=0;j<=100;j++)
delay(10);
setcolor(WHITE);
line(500,20,500,i);
delay(10);
line(502,18,502,i+2);
}
for(i=500;i>=130;i--)
{for(j=100;j>=0;j--)
delay(10);
setcolor(WHITE);
line(500,460,i,460);
delay(10);
line(502,462,i-2,462);
}
for(i=460;i>=20;i--)
{for(j=100;j>=0;j--)
delay(10);
setcolor(WHITE);
line(130,460,130,i);
delay(10);
line(128,462,128,i-2);
}
setcolor(WHITE);
settextstyle(4,0,7);
outtextxy(140,30,"qing xuan zhe yao jing xing de cao zuo:");
settextstyle(4,0,3);
outtextxy(185,80,"Z:");
outtextxy(205,80,"hua chu zhi xian.");
box(230,90,490,120,7);
setfillstyle(1,11);
floodfill(250,105,7);
settextstyle(4,0,7);
outtextxy(210,90,"d:");
outtextxy(230,90,"dda suan fa hua zhi xian.");
outtextxy(210,105,"m:");
outtextxy(230,105,"zhong dian suan fa hua zhi xian.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,125,"Y:");
outtextxy(205,125,"hua chu yuan.");
setcolor(11);
box(230,140,490,170,7);
setfillstyle(1,11);
floodfill(250,145,7);
settextstyle(4,0,7);
outtextxy(210,140,"m:");
outtextxy(230,140,"zhong dian suan fa hua yuan.");
outtextxy(210,155,"z:");
outtextxy(230,155,"zheng fu fa hua yuan.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,175,"T:");
outtextxy(205,175,"hua chu tuo yuan.");
setcolor(11);
box(230,190,490,220,7);
setfillstyle(1,11);
floodfill(250,215,7);
outtextxy(210,190,"m:");
outtextxy(230,190,"zhong dian suan fa hua yuan.");
outtextxy(210,205,"w:");
outtextxy(230,205,"wei bu suan fa hua yuan.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,230,"Q:");
outtextxy(205,230,"hua chu qu xian.");
setcolor(11);
box(230,240,490,270,7);
setfillstyle(1,11);
floodfill(250,265,7);
outtextxy(210,240,"h:");
outtextxy(230,240,"hemit qu xian.");
outtextxy(210,255,"b:");
outtextxy(230,255,"breiz qu xian.");
setcolor(11);
setfillstyle(1,11);
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,280,"C:");
outtextxy(205,280,"duo bian xing cai jian.");
settextstyle(4,0,3);
outtextxy(185,310,"A:");
outtextxy(205,310,"qu yu tian chong.");
settextstyle(4,0,3);
outtextxy(185,340,"D:");
outtextxy(205,340,"xian shi zi fu.");
setfillstyle(1,11);
setcolor(WHITE);
outtextxy(185,370,"X:");
outtextxy(205,370,"duo bian xing xuan zhuang. ");
setfillstyle(1,11);
settextstyle(4,0,3);
outtextxy(185,400,"E:");
outtextxy(205,400,"tui chu chen xu.");
}
/******************************************************************/
/********************************************************************/
jingzhimenu()
{/*int graphdriver=VGA;
int graphmode=VGAHI;
initgraph(&graphdriver,&graphmode,""); */
initgr();
cleardevice();
setbkcolor(1);
drawmat(xin48L,48,20,150,YELLOW);
drawmat(ke48L,48,60,150,YELLOW);
draw_0(26,200);
draw_3(46,200);
draw_0(66,200);
draw_1(82,200);
setcolor(WHITE);
settextstyle(4,0,7);
outtextxy(140,30,"qing xuan zhe yao jing xing de cao zuo:");
settextstyle(4,0,3);
outtextxy(185,80,"Z:");
outtextxy(205,80,"hua chu zhi xian.");
box(230,90,490,120,7);
setfillstyle(1,11);
floodfill(250,105,7);
settextstyle(4,0,7);
outtextxy(210,90,"d:");
outtextxy(230,90,"dda suan fa hua zhi xian.");
outtextxy(210,105,"m:");
outtextxy(230,105,"zhong dian suan fa hua zhi xian.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,125,"Y:");
outtextxy(205,125,"hua chu yuan.");
setcolor(11);
box(230,140,490,170,7);
setfillstyle(1,11);
floodfill(250,145,7);
settextstyle(4,0,7);
outtextxy(210,140,"m:");
outtextxy(230,140,"zhong dian suan fa hua yuan.");
outtextxy(210,155,"z:");
outtextxy(230,155,"zheng fu fa hua yuan.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,175,"T:");
outtextxy(205,175,"hua chu tuo yuan.");
setcolor(11);
box(230,190,490,220,7);
setfillstyle(1,11);
floodfill(250,215,7);
outtextxy(210,190,"m:");
outtextxy(230,190,"zhong dian suan fa hua yuan.");
outtextxy(210,205,"w:");
outtextxy(230,205,"wei bu suan fa hua yuan.");
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,230,"Q:");
outtextxy(205,230,"hua chu qu xian.");
setcolor(11);
box(230,240,490,270,7);
setfillstyle(1,11);
floodfill(250,265,7);
outtextxy(210,240,"h:");
outtextxy(230,240,"hemit qu xian.");
outtextxy(210,255,"b:");
outtextxy(230,255,"breiz qu xian.");
setcolor(11);
setfillstyle(1,11);
setcolor(WHITE);
settextstyle(4,0,3);
outtextxy(185,280,"C:");
outtextxy(205,280,"duo bian xing cai jian.");
settextstyle(4,0,3);
outtextxy(185,310,"A:");
outtextxy(205,310,"qu yu tian chong.");
settextstyle(4,0,3);
outtextxy(185,340,"D:");
outtextxy(205,340,"xian shi zi fu.");
setfillstyle(1,11);
setcolor(WHITE);
outtextxy(185,370,"X:");
outtextxy(205,370,"duo bian xing xuan zhuang. ");
settextstyle(4,0,3);
outtextxy(185,400,"E:");
outtextxy(205,400,"tui chu chen xu.");
line(130,20,500,20);
delay(10);
line(128,18,502,18);
line(500,20,500,460);
delay(10);
line(502,18,502,462);
line(500,460,130,460);
delay(10);
line(502,462,128,462);
line(130,460,130,20);
delay(10);
line(128,462,128,18);
}
/*******************************************************************/
/********************************************************************/
/*结束函数*/
/************************************************************************/
/*************************************************************************/
int end()
{int i;
for(i=0;i<=15;i++)
{cleardevice();
setcolor(i);
settextstyle(3,0,i-5);
outtextxy(100,100,"xie xie guan kuan!!!");
delay(1000000000);}
setcolor(3);
settextstyle(3,0,7);
outtextxy(200,250,"Bye......");
for(i=0;i<=15;i++)
delay(100000);
outtextxy(200,250,"Bye......");
closegraph();
exit(0);
}
/***********************************************************************/
/***************************************************************************/
/*画直线*/
/*************************************************************************/
/**************************************************************************/
/*DDA算法*/
void DDAline(int x0,int y0,int x1,int y1)
{
int dx,dy,epsl,k;
float x,y,xIncre,yIncre;
dx=x1-x0;
dy=y1-y0;
x=x0; y=y0;
if(abs(dx)>abs(dy))
epsl=abs(dx);
else epsl=abs(dy);
xIncre=(float)dx/(float)epsl;
yIncre=(float)dy/(float)epsl;
for(k=0;k<=epsl;k++)
{if(getpixel((int)(x+0.5),(int)(y+0.5))==0)
putpixel((int)(x+0.5),(int)(y+0.5),1);
else putpixel((int)(x+0.5),(int)(y+0.5),0);
x+=xIncre;
y+=yIncre;
}
}
/***********************************************************************/
/************************************************************************/
/*画多边形*/
/***********************************************************************/
/**************************************************************************/
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()
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -