6 Image *hrhand, *minhand;
10 circlept(Point c, int r, int degrees)
13 rad = (double) degrees * PI/180.0;
31 if(ntm == tm && eqrect(screen->r, r))
34 ntms = *localtime(ntm);
35 anghr = 90-(ntms.hour*5 + ntms.min/12)*6;
36 angmin = 90-ntms.min*6;
39 c = divpt(addpt(r.min, r.max), 2);
40 rad = Dx(r) < Dy(r) ? Dx(r) : Dy(r);
44 draw(screen, screen->r, back, nil, ZP);
46 fillellipse(screen, circlept(c, rad, i*(360/12)), 2, 2, dots, ZP);
48 line(screen, c, circlept(c, (rad*3)/4, angmin), 0, 0, 1, minhand, ZP);
49 line(screen, c, circlept(c, rad/2, anghr), 0, 0, 1, hrhand, ZP);
51 flushimage(display, 1);
57 if(new && getwindow(display, Refnone) < 0)
58 fprint(2,"can't reattach to window");
68 char *mstr[] = {"exit", 0};
72 if (initdraw(0, 0, "clock") < 0)
73 sysfatal("initdraw failed");
74 back = allocimagemix(display, DPalebluegreen, DWhite);
76 hrhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DDarkblue);
77 minhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPaleblue);
78 dots = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DBlue);
92 if(emenuhit(3, &m, &menu) == 0)
95 } else if(key == timer) {