用easyx画电子钟_大佬们求指教,用EasyX画出这样的钟的框架

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

//struct

typedef struct

{

int x0;

int y0;

int x1;

int y1;

int x00;

int y00;

int x11;

int y11;

double cnt;

double step;

int r;

}NeedlePOS;

typedef struct

{

float H;

float S;

float L;

float changestep;

}HSLVAR;

NeedlePOS Needlesec, NeedleMinu, NeedleHour;

HSLVAR Chgcolor;

//variable

char secflag = 0;

char startflag = 0xff;

//画出钟的框架

void DrawTimeFrame(void)

{

int x0, y0, x1, y1, x2, y2;

double i, step = PI / 30.;

int cnt = 0, dispcnt = 0;

char s[3];

setlinestyle(PS_SOLID, 2);

circle(240, 240, 200);

for (i = PI / 2.; i < 2 * PI + PI / 2.; i += step)

{

cnt++;

x0 = (int)(240 - 200 * cos(i));

x1 = (int)(240 - 190 * cos(i));

y0 = (int)(240 - 200 * sin(i));

y1 = (int)(240 - 190 * sin(i));

x2 = (int)(240 - 220 * cos(i));

y2 = (int)(240 - 220 * sin(i));

if (fabs(i - PI / 2.) < EPSILON)

{

x1 = (int)(240 - 170 * cos(i));

y1 = (int)(240 - 170 * sin(i));

line(x0, y0, x1, y1);

circle(x0, y0, 3);

sprintf(s, "%d", 12);

outtextxy(x2 - 6, y2, s);

cnt = 1;

dispcnt++;

}

else if (fabs(i - PI) < EPSILON)

{

x1 = (int)(240 - 170 * cos(i));

y1 = (int)(240 - 170 * sin(i));

line(x0, y0, x1, y1);

circle(x0, y0, 3);

sprintf(s, "%d", 3);

outtextxy(x2 - 3, y2 - 8, s);

cnt = 1;

dispcnt++;

}

else if (fabs(i - 1.5*PI) < EPSILON)

{

x1 = (int)(240 - 170 * cos(i));

y1 = (int)(240 - 170 * sin(i));

line(x0, y0, x1, y1);

circle(x0, y0, 3);

sprintf(s, "%d", 6);

outtextxy(x2 - 3, y2 - 8, s);

cnt = 1;

dispcnt++;

}

else if (fabs(i - 2 * PI) < EPSILON)

{

x1 = (int)(240 - 170 * cos(i));

y1 = (int)(240 - 170 * sin(i));

line(x0, y0, x1, y1);

circle(x0, y0, 3);

sprintf(s, "%d", 9);

outtextxy(x2, y2 - 8, s);

cnt = 1;

dispcnt++;

}

else

{

if (cnt % 6 == 0)

{

x1 = (int)(240 - 170 * cos(i));

y1 = (int)(240 - 170 * sin(i));

line(x0, y0, x1, y1);

circle(x0, y0, 3);

sprintf(s, "%d", dispcnt++);

outtextxy(x2, y2 - 8, s);

cnt = 1;

}

else

{

line(x0, y0, x1, y1);

circle(x0, y0, 3);

}

}

}

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值