summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/meta-imp-tab.mkiv
blob: a4affbea458bbcddfe0963a17709a9c130002d63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
%D \module
%D   [       file=meta-tab,
%D        version=2003.03.21, % very old but now with splitter
%D          title=\METAPOST\ Graphics,
%D       subtitle=Dummy (External) Graphics,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\startuseMPgraphic{TallyBar}
    height := (10/12) * LineHeight ;
    span   := ( 4/10) * LineHeight ;
    drift  := ( 1/10) * LineHeight ;
    def d = (uniformdeviate drift) enddef ;
    for i := 1 upto \MPvar{n} :
        draw
            if (i mod 5)=0 :
                ((-d-4.5span,d)--(+d-0.5span,height-d))
            else :
                ((-d,+d)--(+d,height-d))
            fi
            shifted (span*i,d-drift) withpen pencircle ;
    endfor ;
    currentpicture := currentpicture scaled .75 ;
\stopuseMPgraphic

\setupMPvariables
  [TallyBar]
  [n=0]

\unexpanded\def\tallynumeral#1%
  {\dontleavehmode
   \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=#1}}}

\unexpanded\def\tallynumerals#1%
  {\dontleavehmode
   \begingroup
   \scratchcounter#1\relax
   \doloop
     {\ifnum\scratchcounter>\plusfive
        \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=5}}%
        \advance\scratchcounter-\plusfive
        \space
      \else
        \lower.25\exheight\hbox{\useMPgraphic{TallyBar}{n=\the\scratchcounter}}%
        \exitloop
      \fi}%
   \endgroup}

\let\FunnyBar\tallynumeral

\defineconversion[tally][\tallynumerals]

\continueifinputfile{meta-imp-tab.mkiv}

\starttext

    \starttabulate[|pr|c|]
        \NC \tallynumerals {24} \NC        \NR
        \NC \tallynumerals {12} \NC \times \NR
        \HL
        \NC \tallynumerals{288} \NC      = \NR
    \stoptabulate

    \tallynumerals{"FFFF}

\stoptext

\endinput