meta-imp-tab.mkiv /size: 1898 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=meta-tab,
3%D        version=2003.03.21, % very old but now with splitter
4%D          title=\METAPOST\ Graphics,
5%D       subtitle=Dummy (External) Graphics,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\startuseMPgraphic{TallyBar}
15    height := (10/12) * LineHeight ;
16    span   := ( 4/10) * LineHeight ;
17    drift  := ( 1/10) * 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,height-d))
23            else :
24                ((-d,+d)--(+d,height-d))
25            fi
26            shifted (span*i,d-drift) 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{meta-imp-tab.mkiv}
59
60\starttext
61
62    \starttabulate[|pr|c|]
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