可以随时更换闹钟时刻
八、结论:
时钟显示设计属于动画设计类,它具有动态效果,经过两周的学习与钻研,不断地把时钟显示优质化,使之具有整分钟报时与闹铃功能,虽然在这个过程中遇到了不少困难,但通过查资料基本上能够解决。
附录:源程序清单
#include
9
#include
void DrawHand(int hour, int minute, int second) {
double a_hour, a_min, a_sec; 度值
// 时、分、秒针的弧
int x_hour, y_hour, x_min, y_min, x_sec, y_sec; // 时、分、秒针的末端位置
// 计算时、分、秒针的弧度值 a_sec = second * 2 * PI / 60;
a_min = minute * 2 * PI / 60 + a_sec / 60; a_hour= hour * 2 * PI / 12 + a_min / 12;
// 计算时、分、秒针的末端位置
x_sec = int(120 * sin(a_sec)); y_sec = int(120 * cos(a_sec)); x_min = int(100 * sin(a_min)); y_min = int(100 * cos(a_min)); x_hour= int(70 * sin(a_hour)); y_hour= int(70 * cos(a_hour));
// 画时针
setlinestyle(PS_SOLID, 10); setcolor(WHITE);
line(320 + x_hour, 240 - y_hour, 320 - x_hour / 7, 240 + y_hour / 7);
// 画分针
setlinestyle(PS_SOLID, 6); setcolor(BLUE);
line(320 + x_min, 240 - y_min, 320 - x_min / 5, 240 + y_min / 5);
// 画秒针
setlinestyle(PS_SOLID, 2);
10
}
setcolor(YELLOW);
line(320 + x_sec, 240 - y_sec, 320 - x_sec / 3, 240 + y_sec / 3);
void DrawDial() { }
void main() { pi=q; int x1,y1,w;
11
// 绘制一个简单的表盘 circle(320, 240, 2); circle(320, 240, 60); circle(320, 240, 160);
outtextxy(280, 310, \
// 绘制刻度 int x, y;
for (int i=0; i<60; i++) {
x = 320 + int(145 * sin(PI * 2 * i / 60)); y = 240 + int(145 * cos(PI * 2 * i / 60));
if (i % 15 == 0) }
bar(x - 5, y - 5, x + 5, y + 5); circle(x, y, 3); putpixel(x, y, YELLOW); else if (i % 5 == 0) else
int Yhour=0,Yminute=0;int kk=300; char
q[9]={'1','2','3','4','5','6','7','8','9'},s[2],*pi;
loop1: initgraph(640, 480);
DrawDial();
// 初始化 640 x 480 的绘图窗口 // 绘制表盘
setwritemode(R2_XORPEN); // 设置 XOR 绘图模式
// 绘制表针
setcolor(LIGHTGRAY); outtextxy(314,100,\ x1=315+(int)(140*sin(55*D)); y1=240-(int)(140*cos(55*D)); outtextxy(x1,y1,\ x1=318+(int)(135*sin(50*D)); y1=240-(int)(135*cos(50*D)); outtextxy(x1,y1,\
for(w=0;w<9;w++) {
if(w==2||w==8) {
x1=318+(int)(130*sin((w+1)*5*D)); y1=230-(int)(130*cos((w+1)*5*D)); } else {
x1=318+(int)(130*sin((w+1)*5*D)); y1=230-(int)(130*cos((w+1)*5*D)); }
outtextxy(x1,y1,*(pi+w)); }
SYSTEMTIME ti; while(1) {
// 定义变量保存当前时间
// 死循环
// 获取当前时间
12
GetLocalTime(&ti);