电波发射

DBFS.C



/* 电波发射 DBFS.C 程序设计:谢春 2000.1.1.*/

#include"graphics.h" /*调用图形库函数*/
#include"math.h" /*调用数学函数*/
#include"stdio.h" /*调用标准I/O函数*/
#define PI 3.141596 /*宏定义PI字符串*/

main() /*主函数*/
{
float i;
int b,n,r1,r2,x=155,y=250; /*定义单精度浮点型变量*/
int gdriver=DETECT,gmode; /*定义整型变量gdriver,gmode*/
initgraph(&gdriver,&gmode," "); /*定义变量后,初始化图形系统*/

cleardevice();
setbkcolor(1);
printf("\n");
printf(" 半径递增\n");
printf(" 圆形 椭圆形\n");
printf(" 电波发射\n");
printf(" C 语言图形程序设计\n");
printf("\n");
printf(" 画像素点函数:\n");
printf(" putpixel(x-r1*cos(i),\n");
printf(" y-r2*sin(i),b)\n");
printf("\n");
printf(" 绘制图形语句:\n");
printf(" 圆形 椭圆形电波发射\n");
printf(" for(r2=0;r2<=100;r2++)\n");
printf(" for(i=0;i<=2*PI;i+=PI/999)\n");
printf(" {\n");
printf(" b=r2/7+1,r1=r2\n");
printf(" putpixel(x-r1*cos(i),\n");
printf(" y-100-r2*sin(i),b)\n");
printf(" }\n");
printf("\n");
printf(" 半径递增 圆形 椭圆形电波发射\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); /*设置右窗口*/

/*圆形电波发射*/
for(r2=0;r2<=100;r2++)
for(i=0;i<=2*PI;i+=PI/999)
{
b=r2/7+1,r1=r2;
putpixel(x-r1*cos(i),y-100-r2*sin(i),b);
}

/*椭圆形电波发射*/
for(r2=0;r2<=100;r2++)
for(i=0;i<=2*PI;i+=PI/999)
{
b=r2/7+1,r1=1.5*r2;
putpixel(x-r1*cos(i),y+100-r2*sin(i),b);
}

getch();
clearviewport();
}
closegraph();
}