圆形旋转背景图案

 1 #include<graphics.h>
 2 #include<conio.h>
 3 #include<math.h>
 4 const double PI=3.14;//这里也可以用#define PI 3.14
 5 int main()
 6 {
 7     initgraph(640,480);
 8     int c;
 9     double a;
10     int x,y,r=200;
11     for(a=0;a<=PI*2;a+=0.0001)//0.0001控制圆旋转的速度,数值越大旋转越快
12     {
13         x=(int)(r*cos(a)+320+0.5);
14         y=(int)(r*sin(a)+240+0.5);
15         c=(int)(a*255/(2*PI)+0.5);//若2*PI没有括号,出来的图案将是几个小的扇形
16         setcolor(RGB(0,0,c));
17         line(320,240,x,y);
18     }
19     getch();
20     closegraph();
21 }
View Code

 

posted on 2014-04-03 10:37  一颗向上的草莓  阅读(243)  评论(1编辑  收藏  举报