1
2
3
4
5
6
7
8
9
10
11
12
13
14\startuseMPgraphic{TallyBar}
15 height := (1012) LineHeight ;
16 span := ( 410) LineHeight ;
17 drift := ( 110) LineHeight ;
18 def d = (uniformdeviate drift) enddef ;
19 for i := 1 upto \MPvar{n} :
20 draw
21 if (i mod 5)=0 :
22 ((d-4.5span,d)--(d-0.5span,heightd))
23 else :
24 ((d,d)--(d,heightd))
25 fi
26 shifted (spani,ddrift) withpen pencircle ;
27 endfor ;
28 currentpicture := currentpicture scaled .75 ;
29\stopuseMPgraphic
30
31\setupMPvariables
32 [TallyBar]
33 [n=0]
34
35\unexpanded\def\tallynumeral#1
36 {\dontleavehmode
37 \lower.25\exheight\hpack{\useMPgraphic{TallyBar}{n=#1}}}
38
39\unexpanded\def\tallynumerals#1
40 {\dontleavehmode
41 \begingroup
42 \scratchcounter#1\relax
43 \doloop
44 {\ifnum\scratchcounter>\plusfive
45 \lower.25\exheight\hpack{\useMPgraphic{TallyBar}{n=5}}
46 \advance\scratchcounter\plusfive
47 \space
48 \else
49 \lower.25\exheight\hpack{\useMPgraphic{TallyBar}{n=\the\scratchcounter}}
50 \exitloop
51 \fi}
52 \endgroup}
53
54\let\FunnyBar\tallynumeral
55
56\defineconversion[tally][\tallynumerals]
57
58\continueifinputfile{metaimptab.mkiv}
59
60\starttext
61
62 \starttabulate[prc]
63 \NC \tallynumerals {24} \NC \NR
64 \NC \tallynumerals {12} \NC \times \NR
65 \HL
66 \NC \tallynumerals{288} \NC = \NR
67 \stoptabulate
68
69 \tallynumerals{"FFFF}
70
71\stoptext
72
73\endinput
74 |