| 
 
注册时间2004-9-4最后登录1970-1-1 
 | 
 
 发表于 2006-7-4 22:39:00
|
显示全部楼层 
| 刚做的一个,有点丑陋,不要BS偶=.= 
 
  
 
 复制代码struct TIME
{
    int year;
    char month;
    char day;
    char hour;
    char minute;
    char second;
    char week;
};
int size = 30;
struct TIME theTime;
char dateBuf[20];
char week[][3]={"日","一","二","三","四","五","六"};
// 画表盘
void DrawFace(int x, int y)
{
    int i;
    Circle(x, y, size, 0, 0x41);
    for(i=0; i<12; i++)
    {
        Line(x+Cos(30*i)*(size*7/8)/1024, 
             y+Sin(30*i)*(size*7/8)/1024, 
             x+Cos(30*i)*(size)/1024, 
             y+Sin(30*i)*(size)/1024,
             0x41);
    }
    Refresh();
}
// 画指针
void DrawFinger(int x, int y)
{
    GetTime(theTime);
    Circle(x, y, size*3/4, 1, 0x40);
    // 秒针
    Line(x,
         y,
         x+Sin(6*theTime.second)*(size*3/4)/1024,
         y-Cos(6*theTime.second)*(size*3/4)/1024, 
         0x41);
    // 分针
    Line(x, 
         y, 
         x+Sin(6*theTime.minute)*(size*2/3)/1024,  
         y-Cos(6*theTime.minute)*(size*2/3)/1024, 
         0x41);
    // 时针
    Line(x, 
         y, 
         x+Sin(30*theTime.hour+theTime.minute/2)*(size*2/5)/1024,  
         y-Cos(30*theTime.hour+theTime.minute/2)*(size*2/5)/1024, 
         0x41);
    Refresh();
}
// 显示日期
void DrawDate(int x, int y)
{
    Block(x, y, x+strlen(dateBuf)*6, y+12, 0);
    sprintf(dateBuf, "%d年%d月%d日 星期%s",
            theTime.year, 
            theTime.month, 
            theTime.day, 
            week[theTime.week]);
    TextOut(x, y, dateBuf, 1);
    Refresh();
}
void main()
{
    do{
        DrawFace(80, 32);
        DrawFinger(80, 32);
        DrawDate(30, 66);
    }while(!CheckKey(27));
}
 
 
 
 
 
 [此贴子已经被作者于2006-7-5 2:42:22编辑过] 
 | 
 |