1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\startMPcalculation{simplefun}
18
19
20
21 picture DemoClocks[];
22
23 vardef ClockCircle =
24 image(draw fullcircle scaled 10 ;)
25 enddef ;
26
27 vardef ClockPoints =
28 image (
29 for i=1 upto 12 :
30 draw (0,5) rotated ((360 i) 12) withpen pencircle scaled 1 ;
31 endfor ;
32 )
33 enddef ;
34
35 vardef ClockTicks =
36 image (
37 for i=1 upto 12 :
38 draw ((0,4.5)--(0,5.5)) rotated ((360 i) 12) ;
39 endfor ;
40 )
41 enddef ;
42
43 vardef ClockCenter =
44 image (
45 draw origin withpen pencircle scaled 1 ;
46 )
47 enddef ;
48
49 vardef ClockHour =
50 image(
51 draw (origin -- (0,4)) rotated (
52 360 (getparameterdefault "mpsfont" "hour" 0) 12
53 360 (getparameterdefault "mpsfont" "minute" 0) (60 12)
54
55 ) )
56 enddef ;
57
58 vardef ClockMinute =
59 image(
60 draw (origin -- (0,5)) rotated (
61 360 (getparameterdefault "mpsfont" "minute" 0) 60
62 )
63 )
64 enddef ;
65
66 vardef DemoClock =
67 composeglyph(DemoClocks) ;
68 enddef ;
69
70 lmt_registerglyphs [
71 name = "clock",
72 units = 10,
73 width = 10,
74 height = 10,
75 depth = 0,
76 ] ;
77
78 lmt_registerglyph [
79 category = "clock",
80 ] ;
81
82\stopMPcalculation
83
84
85
86
87
88\continueifinputfile{metaimpclock.mkxl}
89
90
91
92\nopdfcompression
93
94\setuplayout[tight]
95
96\setupbodyfont[dejavu]
97
98\definefontfeature[clock][metapost=clock,metafont=clock]
99
100\definefont[ClockFont][Serif*clock]
101
102\starttext
103
104\protected\def\MyClock#1#2
105 {\begingroup
106 \ClockFont
107 \iffontchar\font\privatecharactercode{CLOCK:#1:#2}\else
108
109
110 \setmetaglyph {
111 category {clock}
112 name {CLOCK:#1:#2}
113 code {DemoClock}
114 hour {#1}
115 minute {#2}
116 shapes {
117 { shape {ClockCircle} color {darkred} }
118 { shape {ClockTicks} color {middlegray} }
119
120 { shape {ClockHour} color {darkgreen} }
121 { shape {ClockMinute} color {darkblue} }
122 { shape {ClockCenter} color {middlegray} }
123 }
124 }
125 \fi
126 \setalternate{\twodigits{#1}:\twodigits{#2}}
127 \privatecharacter{CLOCK:#1:#2}
128 \endgroup}
129
130\dorecurse{8}{
131 \begingroup
132 \glyphxscale \numexpr 1000#100\relax
133 \glyphyscale \glyphxscale
134 \veryraggedright
135 \dostepwiserecurse{0}{60}{1}{
136 \MyClock{3}{##1}\hskip\zeropoint plus \onepoint\allowbreak
137 }
138 \blank
139 \endgroup
140}
141\stoptext
142 |