c语言编八卦图形,关于C语言实现一个八卦图!(我代码写好了,求人改动一下)

TurboC下通过!

这个程序是旋转的,我要让它不旋转,静止的显示该如何实现?

改了一上午,越改错误越多!

#include<graphics.h>

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

void mysector(int x,int y,int startangle,int endangle,int rx,int ry);

main()

{

int graphdriver=VGA,graphmode=VGAHI;

int x0=320,y0=240;

int degree=0;

int size=0;

void *buffer=NULL;

int xt=0,yt=0;

struct palettetype palette;

initgraph(&graphdriver,&graphmode,"C:\bc");/*双引号里面为文件所在的路径,例如C:\bc*/

cleardevice();

size=imagesize(160,80,320,320);

buffer=malloc(size);

getimage(160,80,320,320,buffer);

getpalette(&palette);

while(!kbhit())

{

putimage(160,80,buffer,COPY_PUT);

setcolor(15);

circle(x0,y0,160);

degree=(degree+10)%360;

xt=(int)80* sin( (degree+90)*(2*M_PI)/360 ) ;

yt=(int)80* cos( (degree+90)*(2*M_PI)/360 ) ;

setfillstyle(1,15);

mysector(x0,y0, 0+degree,180+degree,160,160);

setfillstyle(1,0);

mysector(x0,y0,180+degree,360+degree,160,160);

setcolor(0);

setfillstyle(1,0);

mysector(x0+xt,y0+yt, 0+degree,180+degree,80,80);

setfillstyle(1,15);

mysector(x0-xt,y0-yt,180+degree,360+degree,80,80);

setcolor(15);

setfillstyle(1,15);

mysector(x0+xt,y0+yt,0,360,30,30);

setcolor(0);

setfillstyle(1,0);

mysector(x0-xt,y0-yt,0,360,30,30);

getimage(160,80,320,320,buffer);

}

getch();

closegraph();

}

void mysector(int x,int y,int startangle,int endangle,int rx,int ry)

{

if(startangle<360 && endangle>360)

{

sector(x, y,startangle, 360,rx,ry);

sector(x, y, 0, endangle-360,rx,ry);

}

else if(startangle==360)

sector(x, y,0,endangle-360,rx,ry);

else if(startangle>360 && endangle>360)

sector(x,y,startangle-360,endangle-360,rx,ry);

else sector(x,y,startangle,endangle,rx,ry);

}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值