Word版可编辑-图形变换C语言课程设计材料精心整理.doc_第1页
Word版可编辑-图形变换C语言课程设计材料精心整理.doc_第2页
Word版可编辑-图形变换C语言课程设计材料精心整理.doc_第3页
Word版可编辑-图形变换C语言课程设计材料精心整理.doc_第4页
Word版可编辑-图形变换C语言课程设计材料精心整理.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

计算机学院 C语言程序设计课程设计报告学号2016-2017学年 第二学期1608220203C语言程序设计课程设计报告题目:图形变换专业:网络工程班级:16(3)姓名:代应豪指导教师:代美丽成绩:计算机学院2017 年 5月 10日目录- 1 -1 设计要求- 2 -2 程序功能- 2 -3 核心算法- 2 -4 程序代码- 2 -5 运行结果- 2 -6 程序创新说明- 3 -参考文献- 3 -C语言图形程序设计主要内容包括图形模式的初始化、基本图形功能、图形窗口以及图形模式下的文本输出等图形函数的使用,以及按键处理和声音等。学生根据C语言图形程序设计指导书,通过编辑、编译、调试、运行示例代码,逐步掌握C语言图形应用程序中常用函数的作用与使用方法,并综合运用C语言程序设计课程所学知识,设计、实现具有创新功能的程序。成果物是一个综合性较好的图形应用程序和项目报告。1 设计要求设计并实现一个独特的图形应用程序。要求程序功能完整;包含屏幕颜色设置、图形绘制与填充、图形窗口设置、图形模式下文本输出、按键操作等;用户界面友好;代码量500行以上。2 程序功能使用if,for,switch,circle,line,arc及另外一些图形化编程函数实现一些画面效果(形状颜色变化,字体颜色大小设置等),最后使用line画线的方法画出中文“再见“二字。3 核心算法大量使用for循环,switch、if判断来实现一些画面的变化;大量使用函数调用的方式来保持代码的整洁;使用delay()函数来延迟两幅画面切换的时间;大量使用图形化编程的函数和方法来实现画面效果。注:流程图无能为力了,不会画。4 程序代码#include#include#include#include/*模块化编程*/*函数调用*/void start();void tuoyuan();void guochang();void kaitou();void huaban();void tree();void moon();void end();void zai();void jian();main()int gdriver;int gmode;int i;int line;clrscr();gdriver=DETECT;initgraph(&gdriver,&gmode,C:TC20BGI);kaitou();start();getch();tuoyuan();delay(800);setbkcolor(15);cleardevice();/*插入眼睛像*/ellipse(320,240,0,360,30,17.5);setcolor(4);circle(320,240,17.5);setfillstyle(1,4);floodfill(320,240,4);/*画颜色渐变同心圆*/for(i=0;i=30;i+)setcolor(i);circle(320,240,20+i*10);delay(80);delay(800);guochang();delay(1000);cleardevice();huaban();moon();tree();delay(500);cleardevice();end();setbkcolor(6);zai();delay(1000);/*开头过渡*/void start()int gd;int gm;gd=DETECT;initgraph(&gd,&gm,C:TC20BGI);randomize();cleardevice();setbkcolor(3);setcolor(4);settextstyle(0,0,2);outtextxy(100,160, tttt ARE YOU READY?!);settextstyle(0,0,2);outtextxy(100,240, Input any key,lets go!); /*画一些形状颜色渐变椭圆*/void tuoyuan()int x=360;int y=160;int driver;int mode=VGAHI;int num=20;int i;int t;int b;driver=DETECT;initgraph(&driver,&mode,C:/TC20/BGI);t=y-30;b=y-30;setbkcolor(0);for(i=0;inum;i+)setcolor(i+2-1);ellipse(200,230,0,360,t,b);t-=5;b+=5;delay(300);for(i=0;i20;i+)setcolor(i+2-1);ellipse(470,240,0,360,t,b);t+=5;b-=5; /*画变色圆周运动*/void guochang()int gdriver;int i;int b;int c;int gmode;gdriver=DETECT;initgraph(&gdriver,&gmode,C:TC20BGI);setbkcolor(13);for(c=1;c9;c+)switch(c)case 1:for(i=1;i640;i+)if(i=1)setcolor(14);for(b=1;b240;b+)line(320, 240, 1, b);elsebreak;case 2:for(i=1;i640;i+)if(i=1)setcolor(4);for(b=240;b480;b+)line(320,240,1,b);elsebreak;case 3:for(i=1;i640;i+)if(i1)setcolor(6);line(320,240,i,479);elsebreak;case 4:for(i=1;i640;i+)if(i=320)setcolor(5);line(320, 240, i,479);elsebreak;case 5:for(i=640;i0;i-)if(i=639)setcolor(10);for(b=480;b240;b-)line(320,240,639,b);elsebreak;case 6:for(i=640;i0;i-)if(i=639)setcolor(3);for(b=240;b0;b-)line(320, 240,639, b);elsebreak;case 7:for(i=640;i0;i-)if(i=320)setcolor(9);line(320,240,i,1);elsebreak;case 8:for(i=640;i0;i-)if(i0)setcolor(12);line(320, 240, i, 1);elsebreak;/*开头*/void kaitou()int i;int a;int b;int c;int gdriver;int gmode;char s30;clrscr();gdriver=DETECT;initgraph(&gdriver, &gmode, C:TC20BGI);setbkcolor(14);cleardevice();for(a=50;a640;)b=50;setcolor(4);circle(a,b,43);setcolor(9);ellipse(a,b,0,360,43,20);ellipse(a,b,0,360,20,43);setcolor(7);ellipse(a,b,0,360,20,10);setcolor(8);circle(a,b,10);setfillstyle(1,8);floodfill(a,b,8);a=a+90;for(b=50;b480;)a=50;setcolor(4);circle(a,b,45);setcolor(9);ellipse(a,b,0,360,21,45);ellipse(a,b,0,360,45,21);setcolor(7);ellipse(a,b,0,360,22.5,12);circle(a,b,12);b=b+95;for(a=50;a640;)b=430;setcolor(4);circle(a,b,43);setcolor(9);ellipse(a,b,0,360,43,20);ellipse(a,b,0,360,20,43);setcolor(7);ellipse(a,b,0,360,20,10);circle(a,b,10);a=a+90;for(b=50;b480;)a=590;setcolor(4);circle(a,b,45);setcolor(9);ellipse(a,b,0,360,21,45);ellipse(a,b,0,360,45,21);setcolor(7);ellipse(a,b,0,360,22.5,12);circle(a,b,12);b=b+95;setviewport(100, 100, 540, 380, 0);setfillstyle(1, 2);setcolor(14);rectangle(0, 0, 439, 279);floodfill(50, 50, 14);setcolor(12);settextstyle(4, 0, 8);outtextxy(20, 20, TCH);setcolor(15);settextstyle(3, 0, 5);outtextxy(120, 120, DREAM START!);setcolor(14);settextstyle(3, 0, 2);outtextxy(120, 200, Please input any key!);getch();closegraph();return 0;/*用math画颜色变化花瓣*/void huaban()float a,e;float x1,y1,x2,y2;int gdriver=DETECT,b;int gmode;initgraph(&gdriver,&gmode,C:/TC20/BGI);cleardevice();setcolor(GREEN);setbkcolor(0);for(b=1;b6;b+)switch(b)case 1:for(a=0.0;a2*3.14;a+=2*3.14/720)e=100*(1+sin(4*a);x1=320+e*cos(a);x2=320+e*cos(a+3.14/5);y1=240+e*sin(a);y2=240+e*sin(a+3.14/5);setcolor(10);line(x1,y1,x2,y2);break;case 2:for(a=0.0;a2*3.14;a+=2*3.14/720)e=100*(1+sin(4*a);x1=320+e*cos(a);x2=320+e*cos(a+3.14/5);y1=240+e*sin(a);y2=240+e*sin(a+3.14/5);setcolor(12);line(x1,y1,x2,y2);break;case 3:for(a=0.0;a2*3.14;a+=2*3.14/720)e=100*(1+sin(4*a);x1=320+e*cos(a);x2=320+e*cos(a+3.14/5);y1=240+e*sin(a);y2=240+e*sin(a+3.14/5);setcolor(14);line(x1,y1,x2,y2);break;case 4:for(a=0.0;a2*3.14;a+=2*3.14/720)e=100*(1+sin(4*a);x1=320+e*cos(a);x2=320+e*cos(a+3.14/5);y1=240+e*sin(a);y2=240+e*sin(a+3.14/5);setcolor(1);line(x1,y1,x2,y2);break;case 5:for(a=0.0;a2*3.14;a+=2*3.14/720)e=100*(1+sin(4*a);x1=320+e*cos(a);x2=320+e*cos(a+3.14/5);y1=240+e*sin(a);y2=240+e*sin(a+3.14/5);setcolor(9);line(x1,y1,x2,y2);break;/*画树*/void tree()setcolor(8);line(80,400,80,440);line(80,440,75,447);line(75,447,91,447);line(91,447,86,440);line(86,440,86,400);line(86,400,80,400);setfillstyle(6,8);floodfill(83,410,8);setcolor(2);line(83,330,55,400);line(55,400,111,400);line(111,400,83,330);setfillstyle(1,2);floodfill(60,390,2);line(83,290,55,360);line(55,360,111,360);line(111,360,83,290);setfillstyle(1,2);floodfill(80,310,2);delay(1000);/*画月亮*/void moon()setcolor(14);circle(570,70,40);setfillstyle(1,14);floodfill(570,70,14);/*倒数第二结尾,过渡*/void end()int gdriver;int gmode;gdriver=DETECT;initgraph(&gdriver,&gmode,C:/TC20/BGI);setbkcolor(3);setcolor(4);settextstyle(0,0,6);outtextxy(90,200, THE END!);setusercharsize(10,1,4,1);settextstyle(3, 0, 2);outtextxy(220, 380, Please input any key!);getch();/*正式结尾*/*用横线拼出“再”*/void zai()int a,b,c,d,e,f,g,h,gdriver;int gmode;gdriver=DETECT;initgraph(&gdriver,&gmode,C:/TC20/BGI);for(a=70;a300;)setcolor(14);line(a,55,a,70);a=a+1;for(b=120;b350;)setcolor(14);line(90,b,105,b);b=b+1;for(c=90;c280;)setcolor(14);line(c,120,c,135);c=c+1;for(d=120;d350;)setcolor(14);line(265,d,280,d);d=d+1;for(e=105;e265;)setcolor(14);line(e,180,e,195);e+=1;for(f=45;f325;)setcolor(14);line(f,240,f,255);f+=1;for(g=70;g=255;)setcolor(14);line(177.5,g,192.5,g);g+=1;for(h=243;h=280;)setcolor(14);line(h,335,h,350);h+=1;jian();getch();/*用横线拼出“见”,并署名*/void jian()int a,b,c,d,e,f,g;for

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论