% SPRITE.STY ( Martin Costabel 22-Dec-1987 , last changed 28-Nov-1988)
% Use: \documentstyle[...,sprite,...]{...} in LaTeX
% or
%      \input sprite.sty                   in plain TeX
%
% New command:
%
% \sprite{cmd}(lins,cols)[wdth,hght] pxls \endsprite
%
% Here:
% cmd is a command sequence which is afterwards the name of the new object.
%     It is defined as \usebox{cmd@box}, so there is also a new box cmd@box.
% wdth and hght are the width and height of the new object.
% pxls is a sequence of lins lines, each of which starts with a `:'(colon),
%     ends with a `|'(vertical bar), and contains cols pixels which are
%     either a `.'(period, meaning a white pixel) or a `B'(capital B,
%     meaning a black pixel). Blank spaces are ignored.
% If lins and cols do not match the actual numbers of lines and columns of
%     your dot pattern, the actual width and height of your new object will
%     not match wdth and hght.
%
% If you want to create one symbol in different sizes
%     without repeating the dot pattern, you can use
%     \definepixels{\nameit}{:..BB..| :BB..BB| etc.} and then
%     \sprite{\symbolinonesize}(n,6)[wd1,ht1] \nameit \endsprite
%     \sprite{\symbolinanothersize}(n,6)[wd2,ht2] \nameit \endsprite etc.
%
%%%% Some code stolen from LATEX.TEX. Can be omitted if used in LaTeX
%\def\newbox{\alloc@4\box\chardef\insc@unt}
%\def\usebox#1{\leavevmode\copy #1\relax}
%\def\@cdr#1#2\@nil{#2}
%\def\@ifnextchar#1#2#3{\let\@tempe #1\def\@tempa{#2}\def\@tempb{#3}\futurelet
%    \@tempc\@ifnch}
%\def\@ifnch{\ifx \@tempc \@sptoken \let\@tempd\@xifnch
%      \else \ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb\fi
%      \fi \@tempd}
%%%% End of stolen code
\newskip{\@pxlwd} \newskip{\@rulewd} \newskip{\@pxlht}
\def\makedotsactive{\catcode`.=\active \catcode`B=\active
   \catcode`:=\active \catcode`|=\active}
\def\makedotsinactive{\catcode`.=12 \catcode`B=11 \catcode`:=12
   \catcode`|=12\relax}
\makedotsactive
\def\sprite#1(#2,#3)[#4,#5]{
   \edef\@sprbox{\expandafter\@cdr\string#1\@nil @box}
   \expandafter\newbox\csname\@sprbox\endcsname
   \edef#1{\expandafter\usebox\csname\@sprbox\endcsname}
   \expandafter\setbox\csname\@sprbox\endcsname =\hbox\bgroup
   \vbox\bgroup
     \@pxlwd=#4 \divide\@pxlwd by #3 \@rulewd=\@pxlwd
     \@pxlht=#5 \divide\@pxlht by #2
     \makedotsactive
     \def .{\hskip \@pxlwd \ignorespaces}
     \def B{\@ifnextchar B{\advance\@rulewd by \@pxlwd}{\vrule
        height \@pxlht width \@rulewd depth 0 pt \@rulewd=\@pxlwd}}
     \def :{\hbox\bgroup\vrule height \@pxlht
        width 0pt depth 0pt\ignorespaces}
     \def |{\vrule height \@pxlht width 0pt depth 0pt\egroup
        \prevdepth= -1000 pt}
   }
\def\endsprite{\egroup\egroup}
\makedotsinactive
%% Idea of \definepixels (doesn't work):
%%    \def\definepixels#1#2{\makedotsactive\def#1{#2}\makedotsinactive}
\def\definepixels#1{\makedotsactive\def\read@pixels##1{\def#1{##1}}
   \expandafter\makedotsinactive\read@pixels}
%%%   End of  sprite.sty  %%%%%%%%%%%%%%%%%
