6 Image
*hrhand
, *minhand
;
10 circlept(Point c
, int r
, int degrees
)
13 rad
= (double) degrees
* PI
/180.0;
32 if(ntm
== tm
&& eqrect(screen
->r
, r
))
35 ntms
= *localtime(ntm
);
36 anghr
= 90-(ntms
.hour
*5 + ntms
.min
/12)*6;
37 angmin
= 90-ntms
.min
*6;
41 c
= divpt(addpt(r
.min
, r
.max
), 2);
42 rad
= Dx(r
) < Dy(r
) ? Dx(r
) : Dy(r
);
46 draw(screen
, screen
->r
, back
, nil
, ZP
);
48 fillellipse(screen
, circlept(c
, rad
, i
*(360/12)), 2, 2, dots
, ZP
);
50 line(screen
, c
, circlept(c
, (rad
*3)/4, angmin
), 0, 0, 1, minhand
, ZP
);
51 line(screen
, c
, circlept(c
, rad
/2, anghr
), 0, 0, 1, hrhand
, ZP
);
53 flushimage(display
, 1);
59 if(new && getwindow(display
, Refnone
) < 0)
60 fprint(2,"can't reattach to window");
68 fprint(2, "usage: clock [-W winsize]\n");
74 main(int argc
, char *argv
[])
79 char *mstr
[] = {"exit", 0};
85 winsize
= EARGF(usage());
92 initdraw(0,0,"clock");
93 back
= allocimagemix(display
, DPalebluegreen
, DWhite
);
95 hrhand
= allocimage(display
, Rect(0,0,1,1), CMAP8
, 1, DDarkblue
);
96 minhand
= allocimage(display
, Rect(0,0,1,1), CMAP8
, 1, DPaleblue
);
97 dots
= allocimage(display
, Rect(0,0,1,1), CMAP8
, 1, DBlue
);
101 timer
= etimer(0, 30*1000);
110 if(emenuhit(3, &m
, &menu
) == 0)
113 } else if(key
== timer
) {