6 Image *hrhand, *minhand;
10 circlept(Point c, int r, int degrees)
13 rad = (double) degrees * PI/180.0;
33 if(ntm == tm && eqrect(screen->r, r))
36 ntms = *localtime(ntm);
37 anghr = 90-(ntms.hour*5 + ntms.min/12)*6;
38 angmin = 90-ntms.min*6;
42 c = divpt(addpt(r.min, r.max), 2);
43 rad = Dx(r) < Dy(r) ? Dx(r) : Dy(r);
47 draw(screen, screen->r, back, nil, ZP);
49 fillellipse(screen, circlept(c, rad, i*(360/12)), 2, 2, dots, ZP);
51 line(screen, c, circlept(c, (rad*3)/4, angmin), 0, 0, 1, minhand, ZP);
52 line(screen, c, circlept(c, rad/2, anghr), 0, 0, 1, hrhand, ZP);
54 flushimage(display, 1);
60 if(new && getwindow(display, Refnone) < 0)
61 fprint(2,"can't reattach to window");
71 char *mstr[] = {"exit", 0};
75 if (initdraw(0, 0, "clock") < 0)
76 sysfatal("initdraw failed");
77 back = allocimagemix(display, DPalebluegreen, DWhite);
79 hrhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DDarkblue);
80 minhand = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DPaleblue);
81 dots = allocimage(display, Rect(0,0,1,1), CMAP8, 1, DBlue);
95 if(emenuhit(3, &m, &menu) == 0)
98 } else if(key == timer) {