有时间了,终于更新了^_^,动态旋转太极图(二)
旋转太极图
完整代码如下:
#include <graphics.h>
#include <math.h>
#define WIDTH 600
#define HEIGHT 600
#define PI 3.14159
int x=300;
int y=300;
float r=200;
float stangle=PI/2;
int main()
{
initgraph(WIDTH,HEIGHT);//窗口宽和高
setbkcolor(WHITE);
cleardevice();
//设置大圆的线颜色和宽度
setlinecolor(BLACK);
setlinestyle(PS_SOLID,3);
circle(x,y,r);//大圆
setfillcolor(BLACK);
fillpie(x-r, y - r, x+r, y + r,stangle+PI,stangle);
BeginBatchDraw();
while(1)
{
stangle+=0.001;
int dx=(int)(r/2*cos(stangle+PI));
int dy=(int)(r/2*sin(stangle+PI));
//上中心圆
setfillcolor(BLACK);
solidcircle(x-dx,y+dy,r/2);
setfillcolor(WHITE);
solidcircle(x-dx,y+dy,r/4);
//下中心圆
setfillcolor(WHITE);
solidcircle(x+dx,y-dy,r/2);
setfillcolor(BLACK);
solidcircle(x+dx,y-dy,r/4);
FlushBatchDraw();
}
EndBatchDraw();
closegraph();
return 0;
}