《计算机技术基础(c语言)课程设计---用c语言描绘玫瑰花》由会员分享,可在线阅读,更多相关《计算机技术基础(c语言)课程设计---用c语言描绘玫瑰花(10页珍藏版)》请在金锄头文库上搜索。
1、计算机技术基础课程设计计算机技术基础课程设计C C 语言语言设计报告设计报告题目题目:用:用 C C 语言描绘玫瑰花语言描绘玫瑰花一、选题背景一、选题背景通过 C 语言的学习,我们知道了可以用 C 语言编写的程序来描绘出优美的画面。玫瑰花是美丽的代表。所以我将画图的程序来实现玫瑰花的图象。二、设计思想二、设计思想本程序将利用图形库函数、数学函数和标准 I/O 函数来实现函数的运行。依靠我们学过的调用函数来实现。图形中玫瑰花的形状是利用画图函数并根据其坐标来实现的,图形中的弧 线是利用曲线函数实现的。主函数的调用函数大多是我们没有学过的initgraph /*初始化图形系统*/cleardevi
2、ce /*清除图形屏幕*/hua /*自己定义的函数*/setcolor /*设置当前画图颜色*/rectangle /*话矩形边框*/getch /*输入字符*/closegraph /*关闭图形系统*/floodfill/*填充一个有界区域*/三、程序流程图:三、程序流程图: NYint ii=1regisiter ii=0I #include #include #include 35#define FNX(x) (int)(xo+(x)*1.0) #define FNY(y) (int)(getmaxy()-(yo+(y)*1.0) #define FNX2(phi) cos(phi)*
3、ac-sin(phi)*bs #define FNY2(phi) cos(phi)*as+sin(phi)*bc /*画旋转的椭圆*/ void elli(int xo,int yo,int a,int b,double theta) int i; double da,c,s,ac,as,bc,bs,xf,yf,phi,x,y; theta=theta*0.01745; da=3*0.1745; c=cos(theta);s=sin(theta); ac=a*c;as=a*s;bc=b*c;bs=b*s; x=FNX2(0);y=FNY2(0); moveto(FNX(x),FNY(y); f
4、or(i=1;i=360;i+) phi=i*da;xf=x*cos(phi)*0.1;yf=b*sin(phi)*0.1; x=FNX2(phi);y=FNY2(phi); lineto(FNX(x),FNY(y); /*花*/ void hua(int x,int y) register i; /*画粉红色玫瑰*/ setcolor(12); arc(x+65,y-60,150,350,8); arc(x+66,y-54,300,470,8); arc(x+65,y-56,30,230,10); arc(x+64,y-57,300,490,17); ellipse(x+73,y-30,25
5、0,450,27,40); ellipse(x+59,y-30,100,290,27,40); ellipse(x+65,y-40,140,270,20,30); setfillstyle(SOLID_FILL,5); floodfill(x+65,y-20,12); /*画红色玫瑰*/ arc(x,y,150,350,12); arc(x+1,y+8,280,470,12); arc(x,y+2,30,230,16); arc(x,y+3,80,240,28); arc(x+2,y+8,180,330,22); arc(x-2,y+2,310,460,25); ellipse(x-12,y+
6、30,120,300,30,40); ellipse(x+10,y+28,250,423,30,42); ellipse(x-4,y+10,290,393,30,40); setfillstyle(SOLID_FILL,4); floodfill(x+5,y+31,12); /*画紫色花骨朵*/ ellipse(x+120,y+5,0,360,15,25); setfillstyle(SOLID_FILL,1); floodfill(x+120,y,12); /*画黄色花骨朵*/ ellipse(x-70,y+10,0,360,14,20); setfillstyle(SOLID_FILL,1
7、4); floodfill(x-70,y+10,12); setcolor(10); /*画红花花萼*/ ellipse(x-15,y+32,190,310,30,35); ellipse(x+16,y+32,235,355,26,35); ellipse(x,y+35,190,350,43,50); arc(x,y+82,190,350,6); setfillstyle(SOLID_FILL,2); floodfill(x,y+75,10); /*画粉花花萼*/ ellipse(x+50,y-48,190,320,22,50); ellipse(x+80,y-48,220,350,22,50
8、); ellipse(x+65,y-28,180,360,36,50); floodfill(x+65,y+18,10); /*画主枝*/ for(i=0;i3;i+) ellipse(x-98,y+100+i,255,371,100,80); ellipse(x-20,y+30+i,260,358,140,140); ellipse(x+224,y+20+i,180,218,160,140); /*画侧枝*/ ellipse(x+70,y+34,180,233,140,140); ellipse(x,y+40,205,255,100,120); ellipse(x+135,y-30,209,
9、249,72,120); ellipse(x,y+20,263,301,100,120); ellipse(x+85,y-10,278,305,100,120); ellipse(x+100,y-62,282,308,90,120); ellipse(x-50,y-10,277,314,30,120); ellipse(x+70,y+80,222,266,52,120); ellipse(x-60,y-45,229,266,52,120); ellipse(x+79,y-45,229,266,52,120); ellipse(x+84,y,224,273,52,120); ellipse(x+
10、110,y+40,240,282,100,120); /*画紫花骨朵花萼*/ ellipse(x+120,y-6,200,340,17,25); ellipse(x+120,y+7,160,380,17,27); floodfill(x+122,y+30,10); /*画黄花骨朵花萼*/ ellipse(x-70,y+15,140,390,17,20); ellipse(x-75,y-10,205,340,10,30); ellipse(x-60,y-10,195,340,5,30); floodfill(x-70,y+32,10); /*画叶*/ /*画右边的叶子*/ elli(x+168,
11、y+282,10,20,-40); elli(x+161,y+281,11,21,-39); elli(x+163,y+283,10,23,-41);elli(x+162,y+282,11,23,-41);elli(x+161,y+253,7,15,262);elli(x+160,y+252,8,16,260); elli(x+159,y+251,7,15,261);elli(x+162,y+252,8,16,263);elli(x+144,y+271,10,17,-16);elli(x+142,y+270,11,16,-15);elli(x+140,y+270,10,18,-16);elli
12、(x+145,y+270,8,16,-15);elli(x+145,y+273,9,15,-14);elli(x+140,y+271,8,16,-15);elli(x+145,y+270,8,14,-13);elli(x+155,y+222,10,21,-46); elli(x+156,y+224,10,20,-45); elli(x+157,y+224,12,20,-43);elli(x+156,y+220,10,22,-45);elli(x+150,y+200,8,16,270); elli(x+152,y+200,7,16,273); elli(x+150,y+204,8,15,270)
13、; elli(x+135,y+220,8,16,-10);elli(x+133,y+220,6,16,-12);elli(x+135,y+223,8,15,-10);elli(x+136,y+220,7,15,-11);elli(x+137,y+221,8,16,-10);elli(x+138,y+220,8,15,-10);elli(x+140,y+222,9,15,-20); elli(x+137,y+222,8,15,-22);elli(x+140,y+220,9,14,-20);elli(x+146,y+144,8,16,-80); elli(x+143,y+144,7,16,-82)
14、; elli(x+145,y+141,8,15,-80);elli(x+130,y+130,6,12,235); elli(x+133,y+130,5,12,234); elli(x+130,y+134,6,11,235);elli(x+125,y+154,7,14,-10); elli(x+123,y+154,6,14,-13); elli(x+125,y+155,7,12,-10); elli(x+78,y+98,6,12,-90); elli(x+79,y+98,5,12,-92); elli(x+78,y+95,6,11,-90); elli(x+60,y+90,5,10,180);e
15、lli(x+65,y+90,4,10,182);elli(x+64,y+87,5,12,180);elli(x+66,y+88,5,13,150); elli(x+64,y+88,4,13,153); elli(x+66,y+84,5,11,150); elli(x+70,y+109,5,10,-45); elli(x+73,y+109,4,10,-43);elli(x+70,y+105,5,9,-45); elli(x+80,y+100,6,11,120);elli(x+83,y+100,4,11,122);elli(x+80,y+103,6,10,120);elli(x+81,y+105,
16、5,10,-55); elli(x+84,y+105,4,10,-53); elli(x+83,y+103,5,12,-55); /*画左边的叶子*/ elli(x-125,y+270,12,24,60); elli(x-122,y+270,13,24,63); elli(x-125,y+273,12,22,60); elli(x-95,y+270,10,20,10); elli(x-98,y+270,13,20,11);elli(x-93,y+275,10,22,10);elli(x-110,y+245,10,20,90); elli(x-112,y+245,11,20,93); elli(x-110,y+246,10,22,90);elli(x-105,y+220,1