毕业设计C语言论文(7)

2019-06-17 09:30

附 录

附用C语言实现计算机绘图源代码:

#include #include #include #include #include

#define W 4471 /* scan code */ #define S 8051 #define A 7777 #define D 8292 #define ESC 283 #define ENTER 7181

#define F1 15104 /* pagedown&up is uesd to change color */ #define F2 15360

#define SPACE 14624 #define C 11875 #define V 12150 #define B 12386 #define N 12654 #define Q 4209 #define X 11640 #define Z 11386

void penmove(int xx,int yy,int lastxx,int lastyy,void (*buf)) {

putimage(xx,yy,buf,XOR_PUT);

- 31 -

putimage(lastxx,lastyy,buf,XOR_PUT); }

void action(int xx,int yy, int lastxx,int lastyy,void(*buf),int xx1,int yy1,int drawmode)

{

if(drawmode==2) {setwritemode(1); setlinestyle(DOTTED_LINE,0,1); line(xx1,yy1,xx,yy); line(xx1,yy1,lastxx,lastyy); }

else{penmove(xx,yy,lastxx,lastyy,buf);} }

int main(void) {

int gdriver=DETECT,mode,errorcode; int i,ucolor;

int ifexit,key,drawmode; void *buf[15];

int x,y,lastx,lasty,x1,y1; int r;

initgraph(&gdriver,&mode,\ errorcode=graphresult(); if(errorcode!=grOk)

{

printf(\ printf(\ getch(); exit(1);

}

cleardevice(); setfillstyle(1,2); setcolor(WHITE); settextstyle(1,0,1);

outtextxy(230,450, \ Graduation design of SU HUA XIAN \

- 32 -

getch();

textcolor(BLUE); setbkcolor(BLUE); setcolor(GREEN);

rectangle(0+5,0+5,getmaxx()-5,getmaxy()-5); line(5,450,635,450); setfillstyle(1,1); x=getmaxx()/2; y=getmaxy()/2; lastx=x; lasty=y;

for(i=0;i<=15;i++) {

putpixel(x,y,i);

buf[i]=malloc(imagesize(x,y,x+1,y+1)); getimage(x,y,x+1,y+1,buf[i]); }

putpixel(x,y,RED); setcolor(0);

drawmode=0; /* 0 is putpixel */ ucolor=0; ifexit=0;

while(!kbhit()&&(!ifexit)) {

key=bioskey(0);

switch(key) {

case W : if(y>5) { y=y-1; action(x,y,lastx,lasty,buf[3],x1,y1,drawmode); lastx=x; lasty=y; }

- 33 -

break; case S : if(y<449) { y=y+1; action(x,y,lastx,lasty,buf[3],x1,y1,drawmode); lastx=x; lasty=y; } break;

case A : if(x>5) { x=x-1; action(x,y,lastx,lasty,buf[3],x1,y1,drawmode); lastx=x; lasty=y; } break;

case D : if(x<(getmaxx()-5)) { x=x+1; action(x,y,lastx,lasty,buf[3],x1,y1,drawmode); lastx=x; lasty=y; } break;

case ESC :ifexit=1; clrscr();

printf( \ This is my graduation design using simple painting procedure\\n of the C language desige, \\n Please press any key to return to the window\

break;

case ENTER : switch (drawmode) {

- 34 -

case 0: putimage(x,y,buf[3],XOR_PUT); putpixel(x,y,ucolor); putimage(x,y,buf[3],XOR_PUT); break; case 1: putimage(x,y,buf[3],XOR_PUT); x1=x; y1=y; drawmode=2; break; case 2: setwritemode(1); setlinestyle(DOTTED_LINE,0,1); line(x1,y1,x,y); setwritemode(0); setlinestyle(SOLID_LINE,0,1); line(x1,y1,x,y); drawmode=0; putimage(x,y,buf[3],XOR_PUT); break;

} /*switch*/ break;

case F1 : if(drawmode!=2) { if(ucolor>0)ucolor--; else ucolor=15; setfillstyle(1,ucolor); bar(10,455,30,470); setcolor(ucolor); } break;

case F2 : if(drawmode!=2) { if(ucolor<15)ucolor++; else ucolor=0; setfillstyle(1,ucolor); bar(10,455,30,470); setcolor(ucolor); } break;

- 35 -


毕业设计C语言论文(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:广播电视概论复习提纲

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: