2 * aclock - ascii clock for UNIX Console
4 * Copyright (c) 2002 by Antoni Sawicki <as@tenoware.com>
5 * Version 1.8 (unix-aalib); Dublin, June 2002
7 * Compile: gcc -O2 aclock-unix-aalib.c -o aclock -laa -lm
18 void cls(int width, int height) {
20 for(x=0; x<=width; x++)
21 for(y=0; y<=height; y++)
22 aa_putpixel(context, x+1, y+1, 0);
25 void draw_circle(int hand_max, int sYcen, int sXcen, int FontHW){
31 x=cos(r*M_PI/180*6)*hand_max*FontHW+sXcen;
32 y=sin(r*M_PI/180*6)*hand_max+sYcen;
52 aa_putpixel(context, x+1, y+1, c);
56 void draw_hand(int minute, int hlenght, int c, int sXcen, int sYcen, int FontHW){
58 float r=(minute-15)*(M_PI/180)*6;
60 for(n=1; n<hlenght; n++){
61 x=cos(r)*n*FontHW+sXcen;
63 aa_putpixel(context,x,y,c);
69 char INFO[]="Copyright (c) 2002 by Antek Sawicki <as@tenoware.com>\n"
70 "Version 1.4; Dublin, Apr 2002\n";
71 char digital_time[15];
73 int sXmax, sYmax, smax, hand_max, sXcen, sYcen;
77 aa_recommendhidisplay("curses");
78 aa_recommendlowdisplay("curses");
80 context = aa_autoinit(&aa_defparams);
83 fprintf(stderr,"Cannot initialize AA-lib. Giving up.\n");
90 sXmax = aa_scrwidth(context) * 2 - 4;
91 sYmax = aa_scrheight(context) * 2 - 4;
98 hand_max = (smax/2)-1;
104 draw_circle(hand_max, sYcen, sXcen, FontHW);
107 draw_hand((ltime->tm_hour*5)+(ltime->tm_min/10), 2*hand_max/3, 255, sXcen, sYcen, FontHW);
108 draw_hand(ltime->tm_min, hand_max-2, 100, sXcen, sYcen, FontHW);
109 draw_hand(ltime->tm_sec, hand_max-2, 33, sXcen, sYcen, FontHW);
111 aa_fastrender(context, 0, 0, sXmax, sYmax);
113 aa_printf(context, sXmax/4-4, sYmax/8, AA_BOLD, ".:ACLOCK:.");
114 aa_printf(context, sXmax/4-4, sYmax/2.5, AA_NORMAL, "[%02d:%02d:%02d]",
115 ltime->tm_hour, ltime->tm_min, ltime->tm_sec);