%%
%% This is file `aeb_tilebg.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% aeb_tilebg.dtx  (with options: `copyright,package')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% aeb_envelope.sty package,          2007-05-14        %%
%% Copyright (C) 2006  D. P. Story                      %%
%%   dpstory@acrotex.net                                %%
%%   storyd@owc.edu                                     %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{aeb_tilebg}
 [2007/05/14 v1.0 Tile a Background (dps)]
\DeclareOption{uselltiling}{%
    \AtEndOfPackage{%
    \let\aeb@currentTileBkgrd\aeb@TileBkgrdLL}%
}
\DeclareOption{draft}{\let\aeb@tilebg@draft=y\AtEndOfPackage{\aeb@DraftMode}}
\let\aeb@tilebg@draft=n
\DeclareOption{ignoreforpaper}{\let\aeb@tilebg@ignoreforpaper=y}
\let\aeb@tilebg@ignoreforpaper=n
\ProcessOptions
\ifeqforpaper
    \if\aeb@tilebg@draft n%
        \if\aeb@tilebg@ignoreforpaper n%
            \AtEndOfPackage{\aeb@DraftMode}%
\fi\fi\fi
\@ifpackageloaded{web}{}{%
    \PackageError{web}{%
        The web package is required for this package%
    }{%
        Add the web package with the usetemplates option\MessageBreak
        in the preamble above this package.
    }%
}
\RequirePackage{graphicx}
\RequirePackage{multido}
\def\@gobblesix{\expandafter\@gobbletwo\@gobblefour}
\def\aeb@DraftMode{\let\setTileBgGraphic\aeb@setTileBgGraphicDraft
\let\autosetScreensizeWithMargins\@gobblesix
\let\aeb@TileBkgrd\@empty\disableTiling}
\let\turnOffTiling\aeb@DraftMode
\newbox\aeb@tilingbox
\newdimen\aeb@tiledim
\newcommand{\aeb@setTileBgGraphicFinal}[2][1]{%
    \let\aeb@TileBkgrd\aeb@currentTileBkgrd
    \global\setbox\aeb@tilingbox=\hbox{\includegraphics[hiresbb,#1]{#2}}%
    \xdef\tileboxwidth{\strip@pt\wd\aeb@tilingbox}%
    \xdef\tileboxheight{\strip@pt\ht\aeb@tilingbox}%
    \xdef\tilewidth{\the\wd\aeb@tilingbox}%
    \xdef\tileheight{\the\ht\aeb@tilingbox}
}
\newcommand{\aeb@setTileBgGraphicDraft}[2][1]{}
\let\setTileBgGraphic\aeb@setTileBgGraphicFinal
\newcommand{\maxiterations}[1]{\def\aebtile@maxiterations{#1}}
\maxiterations{10}
\newcommand{\aeb@TileBkgrdUL}{%
    \aeb@tiledim=\paperheight
    \advance\aeb@tiledim-\tileheight
    \xdef\aeb@startingHeight{\strip@pt\aeb@tiledim}%
    \multido{\rj=\aeb@startingHeight+-\tileboxheight}
        {\aebtile@maxiterations}{%
        \ifdim\rj pt < -\tileheight \multidostop\else
        \multido{\ri=0+\tileboxwidth}{\aebtile@maxiterations}{%
            \ifdim\ri pt > \textscreenwidth\multidostop\else
                \put(\ri,\rj){\copy\aeb@tilingbox}\fi}\fi}%
}
\newcommand{\aeb@TileBkgrdLL}{%
    \multido{\nj=0+\tileboxheight}{\aebtile@maxiterations}{%
        \ifdim\nj pt > \paperheight\multidostop\else
        \multido{\ni=0+\tileboxwidth}{\aebtile@maxiterations}{%
            \ifdim\ni pt > \textscreenwidth\multidostop\else
                \put(\ni,\nj){\copy\aeb@tilingbox}\fi}\fi}%
}
\let\aeb@TileBkgrd\@empty
\let\aeb@currentTileBkgrd\aeb@TileBkgrdUL
\AddToTemplate{aeb@TileBkgrd}
\newcommand{\autosetScreensizeWithMargins}[6]
{%
    \paperwidth=\tilewidth
    \paperwidth=#2\paperwidth
    \edef\theReqWidth{\the\paperwidth}%
    \paperheight=\tileheight
    \paperheight=#1\paperheight
    \edef\theReqHeight{\the\paperheight}%
    \margins@web@save{#3}{#4}{#5}{#6}%
    \screensize@web@save{\theReqHeight}{\theReqWidth} % height, width
}
\@onlypreamble\autosetScreensizeWithMargins
\newcommand{\disableTiling}{\disableTemplate{aeb@TileBkgrd}}
\newcommand{\enableTiling}{\enableTemplate{aeb@TileBkgrd}}
\newcommand{\switchtoLLTiling}{\let\aeb@TileBkgrd\aeb@TileBkgrdLL}
\newcommand{\switchtoULTiling}{\let\aeb@TileBkgrd\aeb@TileBkgrdUL}
\endinput
%%
%% End of file `aeb_tilebg.sty'.