/* 美丽的新疆 MLDXJ.C 程序设计:谢春 1999.6.9.*/ /* a, b : 背景颜色 a=1--9 画笔颜色 b=14--9 */ /* x, y : 水平移动图形 x=0--639 垂直移动图形 y=0--479 */ /* r1,r2: 水平方向半径 r1=0--320 垂直方向半径 r2=0--240 */ /* i, j : 心形曲线叶片 i=1--24 心形曲线弧度 j=0--2*PI */ #include"graphics.h" /*调用图形库函数 */ #include"math.h" /*调用数学函数 */ #include"stdio.h" /*调用标准I/O函数*/ #define PI 3.141596 /*宏定义PI字符串 */ main() /*主函数*/ { int a=1,a1=1,b=10,x=0,y=30,r1=10,r2=10,r3=240,r4=170,i=4,v=1; float j,k,m; /*定义单精度浮点型变量*/ int gdriver=DETECT,gmode; /*定义整型变量gdriver,gmode*/ initgraph(&gdriver,&gmode," "); /*定义变量后,初始化图形系统*/ cleardevice(); setbkcolor(a); printf("\n"); printf(" C 语言图形函数\n"); printf(" 设置清除窗口 setviewport( ); clearviewport( );\n"); printf(" 背景画笔颜色 setbkcolor(); setcolor( );\n"); setcolor(3); /*设置画笔*/ setlinestyle(0,0,3); /*实线线宽3*/ rectangle(2,2,637,477); /*绘制图纸边框*/ printf(" 请选择变换背景颜色次数(1--9): ?\n"); scanf("%d",&a1); printf(" 请选择演示速度(9--99): ?\n"); scanf("%d",&v); cleardevice(); printf(" 美丽的新疆\n"); printf(" 迷人的天云山\n"); printf(" 碧水清溪风相伴,清泉石上流\n"); setcolor(12); settextjustify(1,1); /*水平垂直中心对齐*/ settextstyle(1,0,8); /*三倍笔画字体,水平,放大倍数*/ outtextxy(320,240," XIN JIANG"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf(" 新疆维吾尔自治区\n"); printf(" 伊黎哈萨克自治州\n"); printf(" 2000.1.1.\n"); setcolor(3); /*设置画笔黄色*/ setlinestyle(0,0,3); /*实线线宽3*/ rectangle(2,2,637,477); /*绘制图纸边框*/ putpixel(320,240,b); for (x=30;x<=610;x+=25) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制上边花纹*/ { putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } for (y=65;y<=415;y+=25) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制右边花纹*/ { x=610; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } for (x=610;x>=30;x+=-25) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制下边花纹*/ { y=450; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } for (y=415;y>=65;y+=-25) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制左边花纹*/ { x=30; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } for (k=-11*PI/6;k<=-PI/6;k+=PI/26) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制 C 字符*/ { x=320,y=240,b=13; putpixel(x+r3*cos(k)-r1*cos(i*j)*cos(j),y-r4*sin(k)-r2*cos(i*j)*sin(j),b); } setcolor(10); /*设置画笔浅绿色*/ setlinestyle(3,0,1); /* 线线宽1*/ getch(); for (a=1;a<=a1;a++) { setbkcolor(a); setviewport(40,40,130,130,1); /*设置窗口*/ for (j=0;j<=2*PI;j+=v*PI/99999) /*绘制左上单线花朵*/ { x=45,y=45,r1=40,r2=40,b=13-a,i=2; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } clearviewport(); setviewport(510,40,600,130,1); /*设置窗口*/ for (j=0;j<=2*PI;j+=v*PI/99999) /*绘制右上小花朵*/ { x=45,y=45,r1=35,r2=35,b=14,i=4; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } for (j=0;j<=2*PI;j+=v*PI/99999) /*绘制右上大花朵*/ { x=45,y=45,r1=45,r2=45,b=13-a,i=4; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } clearviewport(); setviewport(510,350,600,440,1); /*设置窗口*/ rectangle(0,0,90,90); for (r2=20;r2<=40;r2+=1) for (j=0;j<=2*PI;j+=v*PI/9999) /*绘制右下花朵生长*/ { x=45,y=45,r1=r2,b=13-a,i=6; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } clearviewport(); setviewport(40,350,130,440,1); /*设置窗口*/ rectangle(0,0,90,90); for (j=0;j<=2*PI;j+=v*PI/99999) /*绘制左下单线花朵*/ { x=45,y=45,r1=40,r2=40,b=13-a,i=8; putpixel(x-r1*cos(i*j)*cos(j),y-r2*cos(i*j)*sin(j),b); } clearviewport(); } getch(); clearviewport(); closegraph(); /*关闭图形系统,返回文本模式*/ }