summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/shade/shade.tex
blob: b7b01ab8097b1a5a5b0c811eb1e89d43e0a59408 (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
%%% shade/shade.tex (or shade.sty)
%%% shade macros for use with shade.mf
%%% see README for licensing and contact information.

\catcode`\:11

\font\grey:=shade at 10truept

\newbox\shade:box
\newdimen\fill:boundary
    \setbox0=\hbox{\grey:\char0\relax}\fill:boundary=\ht0
\newcount\fill:level \newdimen\fill:size \newdimen\fill:goal

\long\def\shade#1{\leavevmode
             \setbox\shade:box=\hbox{#1}%
             \def\shade:column{}\def\shade:row{}%
             \fill:level=5 \fill:goal=\wd\shade:box
                \advance\fill:goal by 2\fill:boundary
             \let\shade:v\relax \Fill: \shade:row\shade:v
             \fill:level=5
             \fill:goal=\ht\shade:box \advance\fill:goal by \dp\shade:box
                \advance\fill:goal by 2\fill:boundary
             \let\shade:h\relax \Fill: \shade:column\shade:h
             \fill:goal=\ht\shade:box \advance\fill:goal by \dp\shade:box
             \setbox0=\vbox to\fill:goal{\offinterlineskip\grey:
                 \def\shade:h##1{%
                     \def\shade:v####1{\char####1##1\relax}%
                     \hbox to \wd\shade:box{\hss\shade:row\hss}}
                 \vss \shade:column \vss
                 }\ht0=\ht\shade:box \dp0=\dp\shade:box
             \rlap{\box0}\box\shade:box
            }
\def\Fill: {\setbox0=\hbox{\grey:\char\fill:level\relax}\fill:size=\ht0 
            \fill:}
\def\fill: #1#2{%
    \ifdim \fill:size>\fill:goal
           \advance\fill:level by-1
            \ifnum \fill:level>-1 \let \fill:next = \Fill:
                            \else \let \fill:next = \fill:stop \fi
     \else \edef#1{#1#2\the\fill:level}\advance\fill:goal by -\fill:size
           \let \fill:next = \fill:
      \fi \fill:next #1#2}
\def\fill:stop#1#2{}

\endinput