/* 线弧圆函数 XHYHS.C 程序设计: 谢 春 2000.1.1.*/ #include"graphics.h" /*调用图形库函数*/ #include"math.h" /*调用数学函数*/ #include"stdio.h" /*调用标准I/O函数*/ #define PI 3.141596 /*宏定义PI字符串*/ main() /*主函数*/ { int a=1,n,x=155,y=250; int gdriver=DETECT,gmode; /*定义整型变量gdriver,gmode*/ initgraph(&gdriver,&gmode,"c:\\tc"); /*定义变量后,初始化图形系统*/ cleardevice(); setbkcolor(a); printf("\n"); printf("\n"); printf(" 直线,矩形,圆弧,圆形,椭圆\n"); printf(" C 语言图形程序设计\n"); printf("\n"); printf(" 线弧圆函数:\n"); printf(" 直线 line(x1,y1,x2,y2)\n"); printf(" 矩形 rectangle(xl,yt,xr,yb)\n"); printf(" 圆弧 arc(x,y,as,ae,r)\n"); printf(" 圆形 circle(x,y,r)\n"); printf(" 椭圆 ellipse(x,y,as,ae,rx,ry)\n"); printf("\n"); printf(" 绘制图形语句:\n"); printf(" 直线,矩形,圆弧,圆形,椭圆\n"); printf(" setcolor(11);\n"); printf(" setlinestyle(3,0,1);\n"); printf(" line(2,y,307,y);\n"); printf(" setlinestyle(0,0,1)\n"); printf(" rectangle(2,2,307,463);\n"); printf(" arc(x-72,y,180,360,72);\n"); printf(" circle(x-72,y,36);\n"); printf(" ellipse(x,y,0,360,148,190);\n"); printf("\n"); printf(" 按任意键继续 !\n"); setcolor(3); setlinestyle(0,0,3); /*实线线宽3*/ rectangle(2,2,637,477); /*绘制图纸边框*/ setcolor(2); setlinestyle(0,0,1); /*实线线宽1*/ rectangle(6,6,318,473); /*绘制左窗口框*/ rectangle(322,6,633,473); /*绘制右窗口框*/ getch(); /*画一幅,擦一幅*/ for (n=0;n<3;n++) /*设置循环演示次数*/ { setviewport(323,7,632,472,1); /*设置右窗口*/ /*绘制直线,矩形*/ setcolor(11); setlinestyle(3,0,1); line(2,y,307,y); /*绘制水平线*/ line(x,50,x,450); /*绘制垂直线*/ setlinestyle(0,0,1); rectangle(2,2,307,463); /*绘制矩形框*/ getch(); /*绘制圆弧*/ setcolor(10); setlinestyle(0,0,3); arc(x-72,y,180,360,72); /*绘制左大圆弧*/ setlinestyle(0,0,3); arc(x+72,y,0,180,72); /*绘制右大圆弧*/ setlinestyle(0,0,1); arc(x-90,y,180,360,18); /*绘制左小圆弧*/ arc(x-54,y,0,180,18); arc(x+54,y,180,360,18); /*绘制右小圆弧*/ arc(x+90,y,0,180,18); getch(); /*绘制圆形,椭圆*/ setcolor(13); setlinestyle(0,0,1); circle(x,y,144); /*绘制圆形(经线)*/ circle(x-72,y,36); /*绘制左小圆*/ circle(x+72,y,36); /*绘制右小圆*/ circle(x-72,y,2); /*绘制左圆心*/ circle(x,y,2); /*绘制中圆心*/ circle(x+72,y,2); /*绘制右圆心*/ setlinestyle(0,0,3); ellipse(x,y,0,360,148,190); /*绘制椭圆(地球)*/ getch(); clearviewport(); } closegraph(); }