%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% doc-fill.tex --- Documentation for `pst-fill PSTricks package
%%
%% Author          : Denis GIROU (CNRS/IDRIS - France) <Denis.Girou@idris.fr>
%% Created the     : Wed Oct 29 18:39:29 1997
%% Last mod. by    : Herbert Voss <voss _at_ pstricks.de>
%% Last mod. the   : Aug 17 2004
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% If there is not `ctandir' installed (from `ltugboat' package)
\begin{filecontents}{ctandir.sty}
%% LaTeX2e file `ctandir.sty'
%% generated by the `filecontents' environment
%% from source `ltubguid' on 1997/06/12.
%%
%
% Experimental CTAN location information macros for use with Donald
% Arseneau's |url.sty|
%
% we need url.sty; we can rely on it to demand anything it needs of
% LaTeX
\IfFileExists{url.sty}%
  {\RequirePackage{url}}%
  {\PackageWarning{ctandir}{You should acquire a copy of url.sty}%
   \newcommand\urldef[3]{\def#1{\texttt{#3}}}%
   \let\url\texttt
  }
%
\newcommand\CTANdirectory[1]{\expandafter\urldef
  \csname CTAN@#1\endcsname\path}
\newcommand\CTANfile[1]{\expandafter\urldef
  \csname CTAN@#1\endcsname\path}
%
% Use the standard label-referencing mechanism to get the warning for
% an undefined label
\newcommand\CTANref[1]{\expandafter\@setref\csname CTAN@#1\endcsname
  \relax{#1}}
\end{filecontents}

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{geometry} 
\usepackage[hang]{caption}         % Improved captions
\usepackage{ctandir}               % For CTAN references
\usepackage{fancyvrb}              % Fancy verbatims
\usepackage{graphicx}              % `graphicx' LaTeX standard package
\usepackage{mflogo}                % For the MetaFont and MetaPost logos
\input{random.tex}                 % Random macros from Donald Arseneau
\usepackage{url}                   % URLs convenient typesetting
\usepackage{multido}               % General loop macro
\usepackage{pstricks}              % PSTricks with the `color' extension
\usepackage{pst-char}              % PSTricks package for character path
\usepackage[tiling]{pst-fill}      % PSTricks package for filling/tiling
\usepackage{pst-grad}              % PSTricks package for gradient filling
\usepackage{pst-node}              % PSTricks package for nodes

% To extend the height used for the text
%\setlength{\textheight}{25cm}
%\setlength{\topmargin}{-1.5cm}

% Aligned labels in a description environment
\newenvironment{Description}[1]{%
\begin{list}{nothing}{\setlength{\leftmargin}{#1}
\setlength{\labelwidth}{\leftmargin}\setlength{\labelsep}{1mm}}}
{\end{list}}

% For macro names
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}

% Define CTAN addresses using the commands of the |ctandir| package
\CTANdirectory{mpattern}{graphics/metapost/macros/mpattern}
\CTANdirectory{pstricks}{graphics/pstricks}
\CTANdirectory{pst-fill.sty}{graphics/pstricks/latex/pst-fill.sty}
\CTANdirectory{pst-fill}{graphics/pstricks/generic/pst-fill.tex}
\CTANdirectory{Roegel}{graphics/metapost/contrib/macros/truchet}
\CTANdirectory{xypic}{macros/generic/diagrams/xypic}

% From ltugboat.cls
% For references
\makeatletter
\newcommand\acro[1]{\textsc{#1}\@}
\def\CTAN{\acro{CTAN}}
\let\texttub\textsl              % redefined in other situations
\def\TUB{\texttub{TUGboat}}
\def\TUG{\TeX\ \UG}
\def\tug{\acro{TUG}}
\def\UG{Users Group}
% For the bibliography 
\let\@internalcite\cite
\def\cite{\def\@citeseppen{-1000}%
    \def\@cite##1##2{(##1\if@tempswa , ##2\fi)}%
    \def\citeauthoryear##1##2##3{##1, ##3}\@internalcite}
\def\etal{et\,al.\@}
\makeatother

% Personal macros (D.G.)
% ----------------------

% Some colors used
\definecolor{LemonChiffon}{rgb}{1.,0.98,0.8}
\definecolor{LightBlue}   {rgb}{0.8,0.85,0.95}
\definecolor{PaleGreen}   {rgb}{0.88,1,0.88}
\definecolor{PeachPuff}   {rgb}{1.0,0.85,0.73}

% To define a unique string for TeX and LaTeX
\newcommand{\AllTeX}{%
{\rm(L\kern-.36em\raise.3ex\hbox{\sc a}\kern-.15em)%
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

% Bibliography style
\bibliographystyle{ltugbib}

% Name macros
\newcommand{\FillPackage}{\textsf{`pst-fill'}}
\newcommand{\XYpic}{%
\leavevmode\hbox{\kern-.1em X\kern-.3em\lower.4ex\hbox{Y\kern-.15em}-pic}}

\makeatletter

% Example environments
% (do not use in them the four JXYZ characters, that we will use
% as escape characters!)

% For highlighting some verbatim sequences (array names, macro names and comments)
\def\HLComment#1{\textit{#1}}
\def\HLEmph#1{\textit{#1}}
\def\HLTeletype#1{\texttt{#1}}
\def\HLReverse#1{{%
\setlength{\fboxsep}{1pt}%
\colorbox{black}{\textcolor{white}{\textbf{#1}}}}}

\def\Example{\FV@Environment{}{Example}}
\def\endExample{%
\end{VerbatimOut}
\Below@Example{\input{\jobname.tmp}}
\endgroup}

\def\CenterExample{\FV@Environment{}{Example}}
\def\endCenterExample{%
\end{VerbatimOut}%
\begin{center}
\Below@Example{\input{\jobname.tmp}}
\end{center}
\endgroup}

\def\SideBySideExample{\FV@Environment{}{Example}}
\def\endSideBySideExample{%
\end{VerbatimOut}%
\SideBySide@Example{\input{\jobname.tmp}}
\endgroup}

\def\FVB@Example{%
\begingroup
\FV@UseKeyValues
\parindent=0pt
\multiply\topsep by 2
\VerbatimEnvironment
\begin{VerbatimOut}[codes={\catcode`\Z=12}]{\jobname.tmp}}

\def\Below@Example#1{%
\VerbatimInput[gobble=0,commentchar=Z,commandchars=JXY,numbersep=3pt,
               frame=single,numbers=left]%
              {\jobname.tmp}
\catcode`\Z=9\relax%
% We suppress the effect of the highlighting macros
\catcode`\J=0\relax%
\catcode`\X=1\relax%
\catcode`\Y=2\relax%
\def\HLComment##1{##1}%
\def\HLEmph##1{##1}%
\def\HLTeletype##1{##1}%
\def\HLReverse##1{##1}%
#1\par}

\def\SideBySide@Example#1{%
\@tempdimb=\FV@XRightMargin
\advance\@tempdimb -5mm
\begin{minipage}[c]{\@tempdimb}
  \fvset{xrightmargin=0pt}
  \catcode`\Z=9\relax%
  % We suppress the effect of the highlighting macros
  \catcode`\J=0\relax%
  \catcode`\X=1\relax%
  \catcode`\Y=2\relax%
  \def\HLComment##1{##1}%
  \def\HLEmph##1{##1}%
  \def\HLTeletype##1{##1}%
  \def\HLReverse##1{##1}%
  #1
\end{minipage}%
\@tempdimb=\textwidth
\advance\@tempdimb -\FV@XRightMargin
\advance\@tempdimb 5mm
\begin{minipage}[c]{\@tempdimb}
  \VerbatimInput[gobble=0,commentchar=Z,commandchars=JXY,
                 numbersep=3pt,frame=single,numbers=left,
                 xleftmargin=5mm,xrightmargin=0pt]{\jobname.tmp}
\end{minipage}}

\makeatother

% Example environments are numbered, framed and indented by 2 spaces
\fvset{gobble=2,frame=single,fontfamily=tt,numbers=left,numbersep=3pt}

% Default PSTricks parameters
\psset{dimen=middle}

% Translation in PSTricks from the one drawn by Emmanuel Chailloux and
% Guy Cousineau for the MLgraph system
% (see /ftp.ens.fr:/pub/unix/lang/MLgraph/version-2.1/MLgraph-refman.ps.gz)
% The kangaroo itself is reproduce from an original picture from Raoul Raba
\newcommand{\DimX}{2.47}
\newcommand{\DimY}{4.8}
\newcommand{\DimXDivTwo}{1.235}

\newcommand{\KangarooItself}[1]{%
% Body
\pspolygon[fillstyle=solid,fillcolor=#1]%
  (52.5,68)(55,72.5)(55.8,76.5)(56.8,79.8)(58.2,83)(60,85.8)(61.5,86.5)
  (64,87)(66,87.5)(67.8,87.3)(70,87)(71.5,87.3)(73,88)(74.7,88.5)
  (76,90.3)(77,91.5)(72.8,93.8)(69,96)(64.5,99)(59.4,103)(56.2,106.3)
  (53,110.5)(49.5,115.5)(47.2,119.9)(45.7,126)(43.2,123)(41.5,121)(37.5,125)
  (37,122.5)(36.8,120)(37,117)(37.6,113.5)(38.6,110)(40,106.3)(42,102.3)
  (43.5,99.5)(45,97)(46.2,94)(46.8,91.7)(47.2,88)(47,83.5)(46.3,80.8)
  (45.3,78.5)(42.5,76.5)(39.5,75.8)(36,75.9)(33,75.9)(29,76.2)(26,77)
  (22.3,77.5)(18,78.4)(12.8,79.3)(8.6,80)(5.5,80.3)(3,80.5)(0,80)
  (-5.2,78.5)(-9,76.3)(-11.2,74.8)(-13,72.5)(-16.5,68)(-16.5,68)(-19.5,62.5)
  (-22,58)(-25.5,53)(-29,48.5)(-32.5,45)(-36,42)(-39,39.5)(-44,37)
  (-49,35)(-51,34)(-53.5,34.5)(-55.5,36)(-56.5,38)(-56.5,40.5)(-55,41.5)
  (-53.5,41)(-51.5,41)(-50.5,43)(-50.5,44.5)(-51,47)(-51.5,47.2)(-56.5,47)
  (-58.5,46.5)(-60,44.7)(-62,42.3)(-63,39.5)(-63.5,36.3)(-63.5,33)(-63.1,29.5)
  (-61.5,26)(-58,23.6)(-54,22.2)(-50.7,22)(-47.5,22)(-44.5,22.3)(-41,23.5)
  (-36.8,25.8)(-33,28)(-28.5,31)(-23.4,35)(-20.2,38.3)(-17,42.5)(-13.5,47.5)
  (-11.2,51.9)(-9.7,58)(-7.2,55)(-5.5,53)(-1.5,57)(-1,54.5)(-0.8,52)
  (-1,49)(-1.6,45.5)(-2.6,42)(-4,38.3)(-6,34.3)(-7.5,31.5)(-9,29)
  (-10.2,26)(-10.8,23.7)(-11.2,20)(-11,15.5)(-10.3,12.8)(-9.3,10.5)(-6.5,8.5)
  (-3.5,7.8)(0,7.9)(3,7.9)(7,8.2)(10,9)(13.7,9.5)(18,10.4)
  (23.2,11.3)(27.4,12)(30.5,12.3)(33,12.5)(36,12)(41.2,10.5)(45,8.3)
  (47.2,6.8)(49,4.5)(52.5,0)(50,4.5)(49.2,8.5)(48.2,11.8)(46.8,15)
  (45,17.8)(43.5,18.5)(41,19)(39,19.5)(37.2,19.3)(35,19)(33.5,19.3)
  (32,20)(30.3,20.5)(29,22.3)(28,23.5)(28,23.5)(24.5,22.3)(21.5,22)
  (18.3,22)(15,22.2)(11,23.6)(7.5,26)(5.9,29.5)(5.5,33)(5.5,36.3)
  (6,39.5)(7,42.3)(9,44.7)(10.5,46.5)(12.5,47)(17.5,47.2)(18,47)
  (18.5,44.5)(18.5,43)(17.5,41)(15.5,41)(14,41.5)(12.5,40.5)(12.5,38)
  (13.5,36)(15.5,34.5)(18,34)(20,35)(25,37)(30,39.5)(33,42)
  (36.5,45)(40,48.5)(43.5,53)(47,58)(49.5,62.5)(52.5,68)
% Eye
\pscircle*[linecolor=white](58.2,98.3){2\psxunit}
\pscircle*(58.2,97.3){\psxunit}
% Mouth
\psline(71.5,88)(70,89.3)(68.5,90.3)(67,91.9)
% Tear
\psline(42,121)(45,118)(47,115.3)(48.5,112.7)(50,110)(51.8,106.5)
       (52.5,103.7)(53,100.5)
\pspolygon(41.2,115.8)(43.2,114.7)(45,112.5)(47,109.8)(48,107)(49.5,104.2)
       (50.5,101.6)(51,98.5)(47.7,100.6)(46,102.2)(44.8,104)(43.5,106)
       (42.5,108)(41.7,110.5)(41,113.2)
}

\newcommand{\Kangaroo}[1]{%
\begin{pspicture}(\DimX,\DimY)
\psset{unit=0.035278}
\KangarooItself{#1}
\end{pspicture}}

\newcommand{\KangarooPstChart}[1]{{%
\psset{xunit=0.006784,yunit=0.00735,linewidth=0.01}
\begin{pspicture}(-65.5,0)(82,126)
\KangarooItself{#1}
\end{pspicture}}}

\begin{document}

\title{\FillPackage\\A PSTricks package for filling and tiling areas}
\author{Timothy van \textsc{Zandt}\thanks{INSEAD,
Economics and Political Science, Fontainebleau, France ---
\mbox{\texttt{<tvz@econ.insead.fr>}}.}\hspace{2mm}{\small (documentation by
Denis \textsc{Girou}\thanks{CNRS/IDRIS --- Centre National de la Recherche
Scientifique / Institut du D\'eveloppement et des Ressources en Informatique
Scientifique, Orsay , France --- \mbox{\texttt{<Denis.Girou@idris.fr>}}.}%
\hspace{1.5mm})}}

\date{\shortstack{December 12, 1997 --- Version 97 patch 2\\
                  {\small Documentation revised June 30, 2000}}}
\maketitle

\begin{center}
\psframebox[framearc=0.3,framesep=5mm,linewidth=0.7mm]{%
  \parbox{11cm}{%
  {\Large\textbf{Abstract}}:
  \FillPackage{} is a PSTricks \cite{vanZandt93}, \cite{Girou94},
  \cite{vanZandtGirou94}, \cite{Hoenig97}, \cite{LGC97} package to draw easily
  various kinds of filling and tiling of areas. It is also a good example of
  the great power and flexibility of PSTricks, as in fact it is a very short
  program (it body is around 200~lines long) but nevertheless really powerful.

  \hspace{5mm} It was written in 1994 by Timothy \textsc{van Zandt} but
  publicly available only in PSTricks 97 and without any documentation.
  We describe here the version \emph{97 patch 2} of December 12, 1997, which
  is the original one modified by myself to manage \emph{tilings} in the
  so-called \emph{automatic} mode. This article would like to serve both of
  reference manual and of user's guide.

  \hspace{5mm} This package is available on \CTAN{} in the
  \texttt{graphics/pstricks} directory (files \texttt{latex/pst-fill.sty} and
  \texttt{generic/pst-fill.tex}).
}}
\end{center}

\section{Introduction}

  Here we will refer as \emph{filling} as the operation which consist to fill
a defined area by a pattern (or a composition of patterns). We will refer as
\emph{tiling} as the operation which consist to do the same thing, but with
the control of the starting point, which is here the upper left corner.
The pattern is positioned relatively to this point. This make an essential
difference between the two modes, as without control of the starting point we
can't draw \emph{tilings} (sometimes  called \emph{tesselations}) as used in
many fields of Art and Science%
\footnote{For an extensive presentation of tilings, in their history and usage
in many fields, see the reference book \cite{GS87}.

  In the \TeX{} world, few work was done on tilings. You can look at the
\emph{tile} extension of the \XYpic{} package \cite{XYpic}, at the articles of
Kees \textsc{van der Laan} \cite[paragraph 7]{LAAN96} (the tiling was in
fact directly done in PostScript) and \cite{LAAN97}, at the \MP{} program
(available on \CTANref{Roegel}) by Denis \textsc{Roegel} for the
\textsc{Truchet} contest in 1995 \cite{EsperetGirou98} and at the \MP{}
package \cite{Bolek98} to draw patterns, which have a strong connection with
tilings.}.

  Nevertheless, as tilings are a wide and difficult field in mathematics, this
package is limited to simple ones, mainly \emph{monohedral} tilings with one
prototile (which can be composite, see section \ref{sec:KindTiles}). With some
experience and wiliness we can do more and obtained easily rather
sophisticated results, but obviously hyperbolic tilings like the famous
\textsc{Escher} ones or aperiodic tilings like the \textsc{Penrose} ones are
not in the capabilities of this package. For more complex needs, we must used
low level and more painfull technics, with the basic \cs{multido}
and \cs{multirput} macros.

\section{Package history and description of it two different modes}

  As already said, this package was written in 1994 by Timothy \textsc{van
Zandt}. Two modes were defined, called respectively \emph{manual} and
\emph{automatic}. For both, the pattern is generated on contiguous positions in
a rather large area which include the region to fill, later cut to the
required dimensions by clipping mechanism. In the first mode, the pattern is
explicitely inserted in the PostScript file each time. In the second one, the
result is the same but with an unique explicit insertion of the pattern and a
repetition done by PostScript. Nevertheless, in this method, the control of
the starting point was loosed, so it allowed only to \emph{fill} a region and
not to \emph{tile} it.

  See the difference between the two modes, \emph{tiling}:
{\psset{unit=0.5}
 \psboxfill{\begin{pspicture}(1,1)\psframe[dimen=middle](1,1)\end{pspicture}}
 \begin{pspicture}(3,3.3)
   \psframe[fillstyle=boxfill](3,3)
 \end{pspicture}
}
and \emph{filling}:
{%
 \makeatletter
\pst@def{BoxFill}<%
  gsave
    gsave \tx@STV CM grestore dtransform CM idtransform
    abs /h ED abs /w ED
    pathbbox
    h div round 2 add cvi /y2 ED
    w div round 2 add cvi /x2 ED
    h div round 2 sub cvi /y1 ED
    w div round 2 sub cvi /x1 ED
    /y2 y2 y1 sub def
    /x2 x2 x1 sub def
    CP
    y1 h mul sub neg /y1 ED
    x1 w mul sub neg /x1 ED
    clip
    y2 {
      /x x1 def
      x2 {
        save CP x y1 T moveto Box restore
        /x x w add def
      } repeat
      /y1 y1 h add def
    } repeat
  currentpoint currentfont grestore setfont moveto>
 \makeatother
%
 \psset{unit=0.5}
 \psboxfill{\begin{pspicture}(1,1)\psframe[dimen=middle](1,1)\end{pspicture}}
 \begin{pspicture}(3,3.3)
   \psframe[fillstyle=boxfill](3,3)
 \end{pspicture}
 or
 \begin{pspicture}(3,3.3)
   \psframe[fillstyle=boxfill](3,3)
 \end{pspicture}
}
as we can see that initial position is arbitrary and dependent of
the current point.

  It's clear that usage of filling is very restrictive comparing to tiling,
as desired effects required very often the possibility to control the starting 
point. So, this mode was of limited interest, but unfortunately the
\emph{manual} one has the very big disadvantage to require very huge amounts
of ressources, mainly in disk space and consequently in printing time.
A small tiling can require sometimes several megabytes in \emph{manual} mode!
So, it was very often not really usable in practice.

It is why I modified the code, to allow tilings in \emph{automatic} mode,
controlling in this mode too the starting point. And most of the time, that is
to say if some special options are not used, the tiling is done exactly in the
region described, which make it faster. So there is no more reason to use the
\emph{manual} mode, apart very special cases where \emph{automatic} one cannot
work, as explained later -- currently, I know only one case.

  To load this modified \emph{automatic} mode, with \LaTeX{} use
simply:\newline 
\verb+\usepackage[tiling]{pst-fill}+\newline
and in plain \TeX{} after:\newline
\verb+\input{pst-fill}+\newline
add the following definition:\newline
\verb+\def\PstTiling{true}+

  To obtain the original behaviour, just don't use the \emph{tiling} optional
keyword at loading.

  Take care than in \emph{tiling} mode, I introduce also some other changes.
First I define aliases on some parameter names for consistancy (all specific
parameters will begin by the \texttt{fill} prefix in this case) and I change
some default values, which were not well adapted for tilings (\texttt{fillsep}
is set to 0 and as explained \texttt{fillsize} set to \texttt{auto}). I rename 
\texttt{fillcycle} to \texttt{fillcyclex}. I also restore normal way so that
the frame of the area is drawn and all line (\texttt{linestyle},
\texttt{linecolor}, \texttt{doubleline}, etc.) parameters are now active (but
there are not in non \emph{tiling} mode). And I also introduce new parameters
to control the tilings (see below).

  \textbf{In all the following examples, we will consider only the
\emph{tiling} mode.}

{\fvset{commandchars=JXY}
  To do a tiling, we have just to define the pattern with the
\Verb+JHLReverseX\psboxfillY+ macro and to use the new \texttt{fillstyle}
\Verb+JHLReverseXboxfillY+.

  Note that tilings are drawn from left to right and top to bottom, which can
have an importance in some circonstances.

  PostScript programmers can be also interested to know that, even in the
\emph{automatic} mode, the iterations of the pattern are managed directly by
the PostScript code of the package which used only PostScript Level 1
operators. The special ones introduced in Level 2 for drawing of patterns
\cite[section 4.9]{PostScript95} are not used.

  And first, for conveniance, we define a simple \cs{Tiling} macro, which
will simplify our examples:

\begin{Verbatim}
  \newcommand{\Tiling}[JHLEmphX2Y][]{%
    \edef\Temp{JHLEmphX#1Y}%
    \begin{pspicture}JHLEmphX#2Y
      \ifx\Temp\empty
        \psframe[fillstyle=JHLEmphXboxfillY]JHLEmphX#2Y
      \else
        \psframe[fillstyle=JHLEmphXboxfillY,JHLEmphX#1Y]JHLEmphX#2Y
      \fi
    \end{pspicture}}
\end{Verbatim}
}

\newcommand{\Tiling}[2][]{%
  \edef\Temp{#1}%
  \begin{pspicture}#2
    \ifx\Temp\empty
      \psframe[fillstyle=boxfill]#2
    \else
      \psframe[fillstyle=boxfill,#1]#2
    \fi
  \end{pspicture}}

\subsection{Parameters}

  There are \textbf{14} specific parameters available to change the way the
filling/tiling is defined, and one debugging option.

\begin{Description}{2cm}
  \item [\HLTeletype{fillangle} (real)\hfill :] the value of the rotation
  applied to the patterns (\emph{Default:~0}).
\end{Description}

  In this case, we must force the tiling area to be notably larger than the
area to cover, to be sure that the defined area will be covered after rotation.

\begin{CenterExample}
  \newcommand{\Square}{%
    \begin{pspicture}(1,1)
      \psframe[dimen=middle](1,1)
    \end{pspicture}}

  \psset{unit=0.5}
  \psboxfill{\Square}
  \Tiling[JHLEmphXfillangleY=JHLReverseX45Y]{(3,3)}\hspace{3cm}
  \Tiling[JHLEmphXfillangleY=JHLReverseX-60Y]{(3,3)}
\end{CenterExample}

\newcommand{\Square}{%
\begin{pspicture}(1,1)\psframe[dimen=middle](1,1)\end{pspicture}}

\begin{Description}{2cm}
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillsepx} (real$|$dim)\hfill :] value of the horizontal
  separation between consecutive patterns (\emph{Default:~0 for
  tilings\footnotemark, 2pt otherwise}).  \footnotetext{This option was added
  by me, is not part of the original package and is available only if the
  \texttt{tiling} keyword is used when loading the package.}
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillsepy} (real$|$dim)\hfill :] value of the vertical
  separation between consecutive patterns (\emph{Default:~0 for
  ti\-lings\footnotemark, 2pt otherwise}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillsep} (real$|$dim)\hfill :] value of horizontal and
  vertical separations between consecutive patterns (\emph{Default:~0 for
  tilings\footnotemark, 2pt otherwise}).
\end{Description}

  These values can be negative, which allow the tiles to overlap.

\fvset{xrightmargin=0cm}
\begin{CenterExample}
  \psset{unit=0.5}
  \psboxfill{\Square}
  \Tiling[JHLEmphXfillsepxY=JHLReverseX2mmY]{(3,3)}\hfill
  \Tiling[JHLEmphXfillsepyY=JHLReverseX1mmY]{(3,3)}\hfill
  \Tiling[JHLEmphXfillsepY=JHLReverseX0.5Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillsepY=JHLReverseX-0.5Y]{(3,3)}
\end{CenterExample}

\begin{Description}{2cm}
  \item [\HLTeletype{fillcyclex}\footnotemark\ (integer)\hfill :] Shift
  coefficient applied to each row (\emph{Default:~0}).
  \footnotetext{It was \texttt{fillcycle} in the original version.}
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillcycley}\footnotemark\ (integer)\hfill :] Same thing for
  columns (\emph{Default:~0}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillcycle}\footnotemark\ (integer)\hfill :] Allow to fix
  both \texttt{fillcyclex} and \texttt{fillcycley} directly to the same value
  (\emph{Default:~0}).
\end{Description}

  For instance, if \texttt{fillcyclex} is 2, the second row of patterns will
be horizontally shifted by a factor of $\frac{1}{2}=0.5$, and by a factor of
0.333 if \texttt{fillcyclex} is 3, etc.). These values can be negative.

\begin{CenterExample}
  \psset{unit=0.5}
  \psboxfill{\Square}
  \newcommand{\TilingA}[1]{\Tiling[JHLEmphXfillcyclexY=JHLReverseX#1Y]{(3,3)}}

  \TilingA{JHLReverseX0Y}\hfill\TilingA{JHLReverseX1Y}\hfill\TilingA{JHLReverseX2Y}\hfill\TilingA{JHLReverseX3Y}

  \vspace{3mm}
  \TilingA{JHLReverseX4Y}\hfill\TilingA{JHLReverseX5Y}\hfill\TilingA{JHLReverseX6Y}\hfill\TilingA{JHLReverseX-3Y}

  \vspace{3mm}
  \Tiling[JHLEmphXfillcycleyY=JHLReverseX2Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillcycleyY=JHLReverseX3Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillcycleyY=JHLReverseX-3Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillcycleY=JHLReverseX2Y]{(3,3)}\hfill
\end{CenterExample}

\begin{Description}{2cm}
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillmovex}\footnotemark\ (real$|$dim)\hfill :] value of the
  horizontal moves between consecutive patterns (\emph{Default:~0}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillmovey}\footnotemark\ (real$|$dim)\hfill :] value of the
  vertical moves between consecutive patterns (\emph{Default:~0}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillmove}\footnotemark\ (real$|$dim)\hfill :] value of
  horizontal and vertical moves between consecutive patterns
  (\emph{Default:~0}).
\end{Description}

  These parameters allow the patterns to overlap and to draw some special
kinds of tilings. They are implemented only for the \emph{automatic} and
\emph{tiling} modes and their values can be negative.

  In some cases, the effect of these parameters will be the same that with the 
\texttt{fillcycle?} ones, but you can see that it is not true for some other
values.

\begin{CenterExample}
  \psset{unit=0.5}
  \psboxfill{\Square}
  \Tiling[JHLEmphXfillmovexY=JHLReverseX0.5Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillmoveyY=JHLReverseX0.5Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillmoveY=JHLReverseX0.5Y]{(3,3)}\hfill
  \Tiling[JHLEmphXfillmoveY=JHLReverseX-0.5Y]{(3,3)}
\end{CenterExample}

\begin{Description}{2cm}
  \item [\HLTeletype{fillsize}
  (auto$|$\{(real$|$dim,real$|$dim)(real$|$dim,real$|$dim)\}) :] The
  choice of \emph{automatic} mode or the size of the area in \emph{manual}
  mode. If first pair values are not given, (0,0) is used. (\emph{Default:
  auto when \emph{tiling} mode is used, {(-15cm,-15cm)(15cm,15cm)}
  otherwise}).
\end{Description}

  As explained in the introduction, the \emph{manual} mode can require very
huge amount of computer ressources. So, it usage is to discourage in front off
the \emph{automatic} mode. It seems only useful in special circonstances, in
fact when the \emph{automatic} mode failed, which is known only in one case,
for some kinds of EPS files, as the ones produce by dump of portions of
screens (see \ref{sec:GraphicFiles}).

\begin{Description}{2cm}
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillloopaddx}\footnotemark\ (integer)\hfill :] number of
  times the pattern is added on left and right positions (\emph{Default:~0}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillloopaddy}\footnotemark\ (integer)\hfill :] number of
  times the pattern is added on top and bottom positions (\emph{Default:~0}).
  \setcounter{footnote}{1}
  \item [\HLTeletype{fillloopadd}\footnotemark\ (integer)\hfill :] number of
  times the pattern is added on left, right, top and bottom positions
  (\emph{Default:~0}).
\end{Description}

  These parameters are only useful in special circonstances, as for complex
patterns when the size of the rectangular box used to tile the area doesn't 
correspond to the pattern itself (see an example in Figure~\ref{fig:Sheeps})
and also sometimes when the size of the pattern is not a divisor of the size
of the area to fill and that the number of loop repeats is not properly
computed, which can occur.

  They are implemented only for the \emph{tiling} mode.

\begin{Description}{2cm}
  \setcounter{footnote}{1}
  \item [\HLTeletype{PstDebug}\footnotemark\ (integer, 0 or 1)\hfill :] to
  require to see the exact tiling done, without clipping (\emph{Default:~0}).
\end{Description}

  It's mainly useful for debugging or to understand better how the tilings
are done. It is implemented only for the \emph{tiling} mode.

\begin{CenterExample}
  \psset{unit=0.3,JHLEmphXPstDebugY=JHLReverseX1Y}
  \psboxfill{\Square}
  \psset{linewidth=1mm}
  \vspace{0.8cm}
  \Tiling{(2,2)}\hspace{3cm}
  \Tiling[fillcyclex=JHLEmphX2Y]{(2,2)}\hspace{4cm}
  \Tiling[fillmove=JHLEmphX0.5Y]{(2,2)}
\end{CenterExample}

\vspace{1cm}
\section{Examples}

  In fact this unique \cs{psboxfill} macro allow a lot a variations and
different usages. We will try here to demonstrate this.

\subsection{Kind of tiles}
\label{sec:KindTiles}

  Of course, we can access to all the power of PSTricks macros to define the
\emph{tiles} (\emph{patterns}) used. So, we can define complicated ones.

  Here we give four other Archimedian tilings (those built with only some
regular polygons) among the twelve existing, first discovered completely by
Johanes \textsc{Kepler} at the beginning of 17th century \cite{GS87}, the two
other \emph{regular} ones with the tiling by squares, formed by a unique
regular polygon, and two other formed by two different regular polygons.

\begin{CenterExample}
  \newcommand{\Triangle}{%
    \begin{pspicture}(1,1)
      \pstriangle[dimen=middle](0.5,0)(1,1)
    \end{pspicture}}
  \newcommand{\Hexagon}{%
    % JHLCommentXsin(60)=0.866Y
    \begin{pspicture}(0.866,0.75)
      \SpecialCoor
      % JHLCommentXHexagonY
      \pspolygon[dimen=middle]
        (0.5;30)(0.5;90)(0.5;150)(0.5;210)(0.5;270)(0.5;330)
    \end{pspicture}}

  \psset{unit=0.5}
  \psboxfill{JHLReverseX\TriangleY}
  \Tiling{(4,4)}\hfill
  % JHLCommentXThe two other regular tilingsY
  \Tiling[fillcyclex=JHLEmphX2Y]{(4,4)}\hfill
  \psboxfill{JHLReverseX\HexagonY}
  \Tiling[fillcyclex=JHLEmphX2Y,fillloopaddy=JHLEmphX1Y]{(5,5)}
\end{CenterExample}

\begin{CenterExample}
  \newcommand{\ArchimedianA}{%
    % JHLCommentXArchimedian tiling 3^2.4.3.4Y
    \psset{dimen=middle}
    % JHLCommentXsin(60)=0.866Y
    \begin{pspicture}(1.866,1.866)
      \psframe(1,1)
      \psline(1,0)(1.866,0.5)(1,1)(0.5,1.866)(0,1)(-0.866,0.5)
      \psline(0,0)(0.5,-0.866)
    \end{pspicture}}
  \newcommand{\ArchimedianB}{%
    % JHLCommentXArchimedian tiling 4.8^2Y
    \psset{dimen=middle,unit=1.5}
    % JHLCommentXsin(22.5)=0.3827 ; cos(22.5)=0.9239Y
    \begin{pspicture}(1.3066,0.6533)
      \SpecialCoor
      % JHLCommentXOctogonY
      \pspolygon(0.5;22.5)(0.5;67.5)(0.5;112.5)(0.5;157.5)
                (0.5;202.5)(0.5;247.5)(0.5;292.5)(0.5;337.5)
    \end{pspicture}}

  \psset{unit=0.5}
  \psboxfill{JHLReverseX\ArchimedianAY}
  \Tiling[fillmove=JHLEmphX0.5Y]{(7,7)}\hfill
  \psboxfill{JHLReverseX\ArchimedianBY}
  \Tiling[fillcyclex=JHLEmphX2Y,fillloopaddy=JHLEmphX1Y]{(7,7)}
\end{CenterExample}

  \setcounter{footnote}{3}
  We can of course tile an area arbitrarily defined. And with the
\texttt{addfillstyle} parameter\footnote{Introduced in PSTricks 97.}, we can
easily mix the \texttt{boxfill} style with another one.

\begin{CenterExample}
  \psset{unit=0.5,dimen=middle}
  \psboxfill{%
    \begin{pspicture}(1,1)
      \psframe(1,1)
      \pscircle(0.5,0.5){0.25}
    \end{pspicture}}
  \begin{pspicture}(4,6)
    \pspolygon[fillstyle=JHLEmphXboxfillY,fillsep=JHLEmphX0.25Y]
              (0,1)(1,4)(4,6)(4,0)(2,1)
  \end{pspicture}
  \hspace{2cm}
  \begin{pspicture}(4,4)
    \pscircle[linestyle=none,fillstyle=solid,fillcolor=yellow,
              JHLReverseXaddfillstyleY=JHLEmphXboxfillY,fillsep=JHLEmphX0.5Y](2,2){2}
  \end{pspicture}
\end{CenterExample}

  Various effects can be obtained, sometimes complicated ones very easily, as
in this example reproduced from one shown by Slavik \textsc{Jablan} in the
field of \emph{OpTiles}, inspired by the \emph{Op-art}:

\begin{CenterExample}
  \newcommand{\ProtoTile}{%
    \begin{pspicture}(1,1)
      % JHLCommentX1/12=0.08333Y
      \psset{linestyle=none,linewidth=0,
             hatchwidth=0.08333\psunit,hatchsep=0.08333\psunit}
      \psframe[fillstyle=solid,fillcolor=black,
               addfillstyle=hlines,hatchcolor=white](1,1)
      \pswedge[fillstyle=solid,fillcolor=white,
               addfillstyle=hlines]{1}{0}{90}
    \end{pspicture}}

  \newcommand{\BasicTile}{%
    \begin{pspicture}(2,1)
      \rput[lb](0,0){\ProtoTile}
      \rput[lb](1,0){\rotateleft{\ProtoTile}}
    \end{pspicture}}

  \ProtoTile\hfill\BasicTile\hfill
  \psboxfill{\BasicTile}
  \Tiling[fillcyclex=JHLEmphX2Y]{(4,4)}
\end{CenterExample}

  It is also directly possible to surimpose several different tilings. Here is
the splendid visual proof of the \textsc{Pytha\-gore} theorem done by the arab
mathematician \textsc{Annairizi} around the year 900, given by superposition
of two tilings by squares of different sizes.

\fvset{xrightmargin=0cm}
\begin{CenterExample}
  \psset{unit=1.5,dimen=middle}
  \begin{pspicture*}(3,3)
    \psboxfill{\begin{pspicture}(1,1)
                 \psframe(1,1)
               \end{pspicture}}
    \psframe[fillstyle=boxfill](3,3)
    \psboxfill{\begin{pspicture}(1,1)
                 \rput{-37}{\psframe[linecolor=red](0.8,0.8)}
               \end{pspicture}}
    \psframe[fillstyle=boxfill](3,4)
    \pspolygon[fillstyle=hlines,hatchangle=90](1,2)(1.64,1.53)(2,2)
  \end{pspicture*}
\end{CenterExample}

  In a same way, it is possible to build tilings based on figurative patterns,
in the style of the famous \textsc{Escher} ones. Following an example of
Andr\'e \textsc{Deledicq} \cite{Deledicq97}, we first show a simple tiling of
the \emph{p1} category (according to the international classification of the
17~symmetry groups of the plane first discovered by the russian
crystalographer Jevgraf \textsc{Fedorov} at the end of the 19th century):

\begin{CenterExample}
  \newcommand{\SheepHead}[1]{%
    \begin{pspicture}(3,1.5)
      \pscustom[liftpen=2,fillstyle=solid,fillcolor=#1]{%
        \pscurve(0.5,-0.2)(0.6,0.5)(0.2,1.3)(0,1.5)(0,1.5)
          (0.4,1.3)(0.8,1.5)(2.2,1.9)(3,1.5)(3,1.5)(3.2,1.3)
          (3.6,0.5)(3.4,-0.3)(3,0)(2.2,0.4)(0.5,-0.2)}
      \pscircle*(2.65,1.25){0.12\psunit} % JHLCommentXEyeY
      \psccurve*(3.5,0.3)(3.35,0.45)(3.5,0.6)(3.6,0.4)% JHLCommentXMuzzleY
      % JHLCommentXMouthY
      \pscurve(3,0.35)(3.3,0.1)(3.6,0.05)
      % JHLCommentXEarY
      \pscurve(2.3,1.3)(2.1,1.5)(2.15,1.7)
      \pscurve(2.1,1.7)(2.35,1.6)(2.45,1.4)
    \end{pspicture}}

  \psboxfill{\psset{unit=0.5}\SheepHead{yellow}\SheepHead{cyan}}
  \Tiling[fillcyclex=JHLEmphX2Y,fillloopadd=JHLEmphX1Y]{(10,5)}
\end{CenterExample}
\label{fig:Sheeps}

  Now a tiling of the \emph{pg} category (the code for the kangaroo itself is
too long to be shown here, but has no difficulties ; the kangaroo is reproduce
from an original picture from Raoul \textsc{Raba} and here is a translation in
PSTricks from the one drawn by Emmanuel \textsc{Chailloux} and Guy
\textsc{Cousineau} for their MLgraph system \cite{MLgraphTSI}):

\begin{CenterExample}
  \psboxfill{%
    \psset{unit=0.4}
    \Kangaroo{yellow}\Kangaroo{red}%
    \Kangaroo{cyan}\Kangaroo{green}%
    \psscalebox{-1 1}{%
      \rput(1.235,4.8){%
        \Kangaroo{green}\Kangaroo{cyan}%
          \Kangaroo{red}\Kangaroo{yellow}}}}
  \Tiling[fillloopadd=JHLEmphX1Y]{(10,6)}
\end{CenterExample}

  And here a \textsc{Wang} tiling \cite{Wang65}, \cite[chapter
11]{GS87}, based on very simple tiles of the form of a square and composed
of four colored triangles. Such tilings are built with only a matching color
constraint. Despite of it simplicity, it is an important kind of tilings, as
\textsc{Wang} and others used them to study the special class of
\emph{aperiodic} tilings, and also because it was shown that surprisingly this 
tiling is similar to a \textsc{Turing} machine.

\begin{CenterExample}
  \newcommand{\WangTile}[4]{%
    \begin{pspicture}(1,1)
      \pspolygon*[linecolor=#1](0,0)(0,1)(0.5,0.5)
      \pspolygon*[linecolor=#2](0,1)(1,1)(0.5,0.5)
      \pspolygon*[linecolor=#3](1,1)(1,0)(0.5,0.5)
      \pspolygon*[linecolor=#4](1,0)(0,0)(0.5,0.5)
    \end{pspicture}}

  \newcommand{\WangTileA}{\WangTile{cyan}{yellow}{cyan}{cyan}}
  \newcommand{\WangTileB}{%
    \WangTile{yellow}{cyan}{cyan}{red}}
  \newcommand{\WangTileC}{%
    \WangTile{cyan}{red}{yellow}{yellow}}

  \newcommand{\WangTiles}[1][]{%
    \begin{pspicture}(3,3)
      \psset{ref=lb}
      \rput(0,2){\WangTileB}%
        \rput(1,2){\WangTileA}%
        \rput(2,2){\WangTileC}
      \rput(0,1){\WangTileC}%
        \rput(1,1){\WangTileB}%
        \rput(2,1){\WangTileA}
      \rput(0,0){\WangTileA}%
        \rput(1,0){\WangTileC}%
        \rput(2,0){\WangTileB}
      #1
    \end{pspicture}}

  \WangTileA\hfill\WangTileB\hfill\WangTileC\hfill
  \WangTiles[{\psgrid[subgriddiv=0,gridlabels=0](3,3)}]\hfill
  \psset{unit=0.4}
  \psboxfill{JHLReverseX\WangTilesY}
  \Tiling{(12,12)}
\end{CenterExample}

\subsection{External graphic files}
\label{sec:GraphicFiles}

  We can also fill an arbitrary area with an external image. We have only, 
as usual, to matter of the \emph{BoundingBox} definition if there is no one
provided or if it is not the accurate one, as for the well known
\texttt{tiger} picture part of the \texttt{ghostscript} distribution.

\begin{CenterExample}
  \psboxfill{% JHLCommentXStrangely require x1=x2...Y
    \begin{pspicture}(0,1)(0,4.1)
      \includegraphics[bb=17 176 560 74,width=3cm]{images/JHLReverseXtigerY}
    \end{pspicture}}
  \Tiling{(6,6.2)}
\end{CenterExample}

  Nevertheless, there are some special files for which the \emph{automatic}
mode doesn't work, specially for some files obtained by a screen dump, as in
the next example, where a picture was reduced before it conversion in the
\emph{Encapsulated PostScript} format by a screen dump utility. In this case,
usage of the \emph{manual} mode is the only alternative, at the price of the
real multiple inclusion of the EPS file. We must take care to specify the
correct \texttt{fillsize} parameter, because otherwise the default values are
large and will load the file many times, perhaps just really using few
occurrences as the other ones would be clipped...

\begin{CenterExample}
  \psboxfill{\includegraphics{images/JHLReverseXflowersY}}
  \begin{pspicture}(8,4)
    \psellipse[fillstyle=JHLEmphXboxfillY,fillsize={(8,4)}](4,2)(4,2)
  \end{pspicture}
\end{CenterExample}

\subsection{Tiling of characters}

  We can also use the \cs{psboxfill} macro to fill the interior of characters
for special effects like these ones:

\begin{CenterExample}
  \DeclareFixedFont{\bigsf}{T1}{phv}{b}{n}{4.5cm}
  \DeclareFixedFont{\smallrm}{T1}{ptm}{m}{n}{3mm}
  \psboxfill{\smallrm JHLReverseXSince 182 days...Y}
  \begin{pspicture*}(8,4)
    \centerline{%
      \pscharpath[fillstyle=gradient,gradangle=-45,
                  gradmidpoint=0.5,addfillstyle=JHLEmphXboxfillY,
                  fillangle=JHLEmphX45Y,fillsep=JHLEmphX0.7mmY]
                 {\rput[b](0,0.1){\bigsf JHLReverseX2000Y}}}
  \end{pspicture*}
\end{CenterExample}

\begin{CenterExample}
  \DeclareFixedFont{\mediumrm}{T1}{ptm}{m}{n}{2cm}
  \psboxfill{%
    \psset{unit=0.1,linewidth=0.2pt}
    \Kangaroo{PeachPuff}\Kangaroo{PaleGreen}%
      \Kangaroo{LightBlue}\Kangaroo{LemonChiffon}%
    \psscalebox{-1 1}{%
      \rput(1.235,4.8){%
        \Kangaroo{LemonChiffon}\Kangaroo{LightBlue}%
          \Kangaroo{PaleGreen}\Kangaroo{PeachPuff}}}}
  % JHLCommentXA kangaroo of kangaroos...Y
  \begin{pspicture}(8,2)
    \pscharpath[linestyle=none,fillstyle=JHLEmphXboxfillY,fillloopadd=JHLEmphX1Y]
               {\rput[b](4,0){\mediumrm JHLReverseXKangarooY}}
  \end{pspicture}
\end{CenterExample}

\subsection{Other kinds of usage}

  Other kinds of usage can be imagined. For instance, we can use tilings in a
sort of degenerated way to draw some special lines made by a unique or
multiple repeating patterns. But it can be only a special dashed line, as here
with three different dashes:

\begin{CenterExample}
  \newcommand{\Dashes}{%
    \psset{dimen=middle}
    \begin{pspicture}(0,-0.5\pslinewidth)(1,0.5\pslinewidth)
      \rput(0,0){\psline(0.4,0)}%
        \rput(0.5,0){\psline(0.2,0)}%
        \rput(0.8,0){\psline(0.1,0)}
    \end{pspicture}}

  \newcommand{\SpecialDashedLine}[3]{%
    \psboxfill{#3}
    \Tiling[linestyle=none]
           {(#1,-0.5\pslinewidth)(#2,0.5\pslinewidth)}}

  \SpecialDashedLine{0}{7}{\Dashes}

  \psset{unit=0.5,linewidth=1mm,linecolor=red}
  \SpecialDashedLine{0}{10}{\Dashes}
\end{CenterExample}

  It allow also to use special patterns in business graphics, as in the
following example generated by \texttt{PstChart}\footnote{A personal
development to draw business charts with PSTricks, not distributed.}.

\vspace{3mm}
\begin{figure}[!ht]
\centering
\psset{unit=0.75}
% Generated by pstchart.sh version 0.21 (11/28/97)
{\psset{dimen=middle}
\psset{xunit=2,yunit=0.005}
\begin{pspicture}(-0.6,-200)(6.6,2300)
  % Title
  \rput(3,2200){\shortstack{Fantaisist repartition of kangaroos\\
                            in the world (in thousands)}}
  % Frame background
  \psframe[fillstyle=solid,fillcolor=LemonChiffon](0,0)(6,2000)
  % Graduations
  \multido{\n=0+500}{5}{\rput[r](-0.12,\n){\psscalebox{0.8}{\n}}}
  % Minor ticks
  \multips(0,100)(0,100){19}{\psline[unit=4.8pt](1,0)}
  \multips(6,100)(0,100){19}{\psline[unit=4.8pt](-1,0)}
  % Major ticks
  \multips(0,500)(0,500){3}{\psline[unit=9.6pt](1,0)}
  \multips(6,500)(0,500){3}{\psline[unit=9.6pt](-1,0)}
  % Lines from major ticks marks
  \multips(0,500)(0,500){3}{\psline[linestyle=dotted,linewidth=0.6pt](6,0)}
  % Drawing for the data
  \psboxfill{\psset{unit=0.78\psxunit}\KangarooPstChart{red}}
  \psframe[linestyle=none,fillstyle=boxfill,fillloopaddy=1](0.61,0)(1.39,1800)
  \psboxfill{\psset{unit=0.78\psxunit}\KangarooPstChart{yellow}}
  \psframe[linestyle=none,fillstyle=boxfill,fillloopaddy=1](1.61,0)(2.39,800)
  \psboxfill{\psset{unit=0.78\psxunit}\KangarooPstChart{cyan}}
  \psframe[linestyle=none,fillstyle=boxfill,fillloopaddy=1](2.61,0)(3.39,550)
  \psboxfill{\psset{unit=0.78\psxunit}\KangarooPstChart{magenta}}
  \psframe[linestyle=none,fillstyle=boxfill,fillloopaddy=1](3.61,0)(4.39,500)
  \psboxfill{\psset{unit=0.78\psxunit}\KangarooPstChart{green}}
  \psframe[linestyle=none,fillstyle=boxfill,fillloopaddy=1](4.61,0)(5.39,200)
  % Bottom labels
  \uput{0.2}[270]{0}(1,0){\psscalebox{0.7}{Oceania}}
  \uput{0.2}[270]{0}(2,0){\psscalebox{0.7}{Africa}}
  \uput{0.2}[270]{0}(3,0){\psscalebox{0.7}{Asia}}
  \uput{0.2}[270]{0}(4,0){\psscalebox{0.7}{America}}
  \uput{0.2}[270]{0}(5,0){\psscalebox{0.7}{Europe}}
  % Frame box around the chart
  \psframe[linestyle=solid](0,0)(6,2000)
\end{pspicture}}
  \caption{Bar chart generated by PstChart, with bars filled by patterns}
  \label{fig:PstChart}
\end{figure}

\section{``Dynamic'' tilings}

  In some cases, tilings used non \emph{static} tiles, that is to say that the 
\emph{prototile(s)}, even if unique, can have several forms, by instance
specified by different colors or rotations, not fixed before generation or
varying each time.

\subsection{Lewthwaite-Pickover-Truchet tiling}

  We give here for example the so-called \emph{Truchet} tiling, which much be
in fact better called \emph{Lewthwaite-Pick\-over-Truchet (LPT)} tiling%
\footnote{For description of the context, history and references about
S\'ebastien \textsc{Truchet} and this tiling, see \cite{EsperetGirou98}.}.

  The unique prototile is only a square with two opposite circle arcs.
This tile has obviously two positions, if we rotate it from 90 degrees (see
the two tiles on the next figure). A \emph{LPT tiling} is a tiling with
randomly oriented LPT tiles. We can see that even if it is very simple in it
principle, it draw sophisticated curves with strange properties.

  Nevertheless, in the straightforward way \FillPackage{} does not work,
because the \cs{psboxfill} macro store the content of the tile used in a
\TeX{} box, which is static. So the calling to the random function is done
only one time, which explain that only one rotation of the tile is used for
all the tiling. It's only the one of the two rotations which could differ from
one drawing to the next one...

% Truchet (Lewthwaite-Pickover-Truchet) tiling
% --------------------------------------------

\begin{CenterExample}
  % JHLCommentXLPT prototileY
  \newcommand{\ProtoTileLPT}{%
    \psset{dimen=middle}
    \begin{pspicture}(1,1)
      \psframe(1,1)
      \psarc(0,0){0.5}{0}{90}
      \psarc(1,1){0.5}{-180}{-90}
    \end{pspicture}}

  % JHLCommentXLPT tileY
  \newcount\Boolean
  \newcommand{\BasicTileLPT}{%
    % JHLCommentXFrom random.tex by Donald ArseneauY
    \setrannum{\Boolean}{0}{1}%
    \ifnum\Boolean=0
      \ProtoTileLPT%
    \else
      \rotateleft{\ProtoTileLPT}%
    \fi}

  \ProtoTileLPT\hfill\rotateleft{\ProtoTileLPT}\hfill
  \psset{unit=0.5}
  \psboxfill{JHLReverseX\BasicTileLPTY}
  \Tiling{(5,5)}
\end{CenterExample}

  But, for simple cases, there is a solution to this problem using a mixture
of PSTricks and PostScript programming. Here the PSTricks
construction \verb+\pscustom{\code{...}}+ allow to insert PostScript code
inside the \LaTeX{} + PSTricks one.

  Programmation is less straightforward, but it has also the advantage to be
notably faster, as all the tilings operations are done in PostScript, and
mainly to not be limited by \TeX{} memory (the \TeX{} + PSTricks solution
I wrote in 1995 for the colored problem was limited to small sizes for this
reason). Just note also that \cs{pslbrace} and \cs{psrbrace} are two
PSTricks macros to define and be able to insert the \verb+{+ and \verb+}+
characters.

\begin{CenterExample}
  % JHLCommentXLPT prototileY
  \newcommand{\ProtoTileLPT}{%
    \psset{dimen=middle}
    \psframe(1,1)
    \psarc(0,0){0.5}{0}{90}
    \psarc(1,1){0.5}{-180}{-90}}

  % JHLCommentXCounter to change the random seedY
  \newcount\InitCounter

  % JHLCommentXLPT tileY
  \newcommand{\BasicTileLPT}{%
    \InitCounter=\the\time
    \pscustom{\code{%
      rand \the\InitCounter\space sub 2 mod 0 eq \pslbrace}}
    \begin{pspicture}(1,1)
      \ProtoTileLPT
    \end{pspicture}%
    \pscustom{\code{\psrbrace \pslbrace}}
    \rotateleft{\ProtoTileLPT}%
    \pscustom{\code{\psrbrace ifelse}}}

  \psset{unit=0.4,linewidth=0.4pt}
  \psboxfill{JHLReverseX\BasicTileLPTY}
  \Tiling{(15,15)}
\end{CenterExample}

  Using the very surprising fact (see \cite{EsperetGirou98}) that
coloration of these tiles do not depend of their neighbors (even if it is
difficult to believe as the opposite seems obvious!) but only of the parity of
the value of row and column positions, we can directly program in the same way
a colored version of the LPT tiling.

\setcounter{footnote}{1}
  We have also introduce in the \FillPackage{} code for \emph{tiling} mode two
new accessible Post\-Script variables, \texttt{row} and
\texttt{column}\footnotemark, which can be useful in some circonstances, like
this one.

\begin{CenterExample}
  % JHLCommentXLPT prototileY
  \newcommand{\ProtoTileLPT}[2]{%
    \psset{dimen=middle,linestyle=none,fillstyle=solid}
    \psframe[fillcolor=#1](1,1)
    \psset{fillcolor=#2}
    \pswedge(0,0){0.5}{0}{90}
    \pswedge(1,1){0.5}{-180}{-90}}

  % JHLCommentXCounter to change the random seedY
  \newcount\InitCounter

  % JHLCommentXLPT tileY
  \newcommand{\BasicTileLPT}[2]{%
    \InitCounter=\the\time
    \pscustom{\code{%
      rand \the\InitCounter\space sub 2 mod 0 eq \pslbrace
      JHLReverseXrowY JHLReverseXcolumnY add 2 mod 0 eq \pslbrace}}
    \begin{pspicture}(1,1)
      \ProtoTileLPT{#1}{#2}
    \end{pspicture}%
    \pscustom{\code{\psrbrace \pslbrace}}
    \ProtoTileLPT{#2}{#1}%
    \pscustom{\code{%
      \psrbrace ifelse \psrbrace \pslbrace JHLReverseXrowY JHLReverseXcolumnY add 2 mod
      0 eq \pslbrace}}
    \rotateleft{\ProtoTileLPT{#2}{#1}}%
    \pscustom{\code{\psrbrace \pslbrace}}
    \rotateleft{\ProtoTileLPT{#1}{#2}}%
    \pscustom{\code{\psrbrace ifelse \psrbrace ifelse}}}

  \psboxfill{JHLReverseX\BasicTileLPT{red}{yellow}Y}
  \Tiling{(4,4)}\hfill
  \psset{unit=0.4}
  \psboxfill{JHLReverseX\BasicTileLPT{blue}{cyan}Y}
  \Tiling{(15,15)}
\end{CenterExample}

  Another classic example is to generate coordinates and numerotation for a
grid. Of course, it is possible to do it directly in PSTricks using nested
\cs{multido} commands. It would be clearly easy to program, but, nevertheless, 
for users who have a little knowledge of PostScript programming, this offer
an alternative which is useful for large cases, because on this way it will
be notably faster and less computer ressources consuming.

  Remember here that the tiling is drawn from left to right, and top to
bottom, and note that the PostScript variable \texttt{x2} give the total
number of columns.

\begin{CenterExample}
  % JHLCommentX\Escape will be the \ characterY
  {\catcode`\!=0\catcode`\\=11!gdef!Escape{\}}

  \newcommand{\ProtoTile}{%
    JHLReverseX\SquareY%
    \pscustom{%
      \moveto(-0.9,0.75) % In PSTricks units
      \code{%
        /Times-Italic findfont 8 scalefont setfont
        (\Escape() show JHLReverseXrowY 3 string cvs show (,) show 
        JHLReverseXcolumnY 3 string cvs show (\Escape)) show}
      \moveto(-0.5,0.25) % In PSTricks units
      \code{%
        /Times-Bold findfont 18 scalefont setfont
        1 0 0 setrgbcolor % Red color
        /center {dup stringwidth pop 2 div neg 0 rmoveto} def
        JHLReverseXrowY 1 sub x2 mul JHLReverseXcolumnY add 3 string cvs center show}}}

  \psboxfill{JHLReverseX\ProtoTileY}
  \Tiling{(6,4)}
\end{CenterExample}

\subsection{A complete example: the Poisson equation}

  To finish, we will show a complete real example, a drawing to explain the
method used to solve the \textsc{Poisson} equation by a domain
decomposition method, adapted to distributed memory computers. The
objective is to show the communications required between processes and the
position of the data to exchange. This code also show some useful and powerful
technics for PSTricks programming (look specially at the way some higher level
macros are defined, and how the same object is used to draw the four
neighbors).

\begin{CenterExample}
  \newcommand{\Pattern}[1]{%
    \begin{pspicture}(-0.25,-0.25)(0.25,0.25)
      \rput{*0}{\psdot[dotstyle=#1]}
    \end{pspicture}}

  \newcommand{\West}{\Pattern{o}}
  \newcommand{\South}{\Pattern{x}}
  \newcommand{\Central}{\Pattern{+}}
  \newcommand{\North}{\Pattern{square}}
  \newcommand{\East}{\Pattern{triangle}}

  \newcommand{\Cross}{%
    \pspolygon[unit=0.5,linewidth=0.2,linecolor=red]
              (0,0)(0,1)(1,1)(1,2)(2,2)(2,1)
              (3,1)(3,0)(2,0)(2,-1)(1,-1)(1,0)}

  \newcommand{\StylePosition}[1]{%
    \LARGE\textcolor{red}{\textbf{#1}}}

  \newcommand{\SubDomain}[4]{%
    \psboxfill{#4}
    \begin{psclip}{\psframe[linestyle=none]#1}
      \psframe[linestyle=#3](5,5)
      \psframe[fillstyle=boxfill]#2
    \end{psclip}}

  \newcommand{\SendArea}[1]{%
    \psframe[fillstyle=solid,fillcolor=cyan]#1}

  \newcommand{\ReceiveData}[2]{%
    \psboxfill{#2}
    \psframe[fillstyle=solid,fillcolor=yellow,
             addfillstyle=boxfill]#1}

  \newcommand{\Neighbor}[2]{%
    \begin{pspicture}(5,5)
      \rput{*0}(2.5,2.5){\StylePosition{#1}}
      \ReceiveData{(0.5,0)(4.5,0.5)}{\Central}
      \SendArea{(0.5,0.5)(4.5,1)}
      \SubDomain{(5,2)}{(0.5,0.5)(4.5,3)}{dashed}{#2}%
      % JHLCommentXReceive and send arrowsY
      \pcarc[arcangle=45,arrows=->](0.5,-1.25)(0.5,0.25)
      \pcarc[arcangle=45,arrows=->,linestyle=dotted,dotsep=2pt]
            (4.5,0.75)(4.5,-0.75)
    \end{pspicture}}

  \psset{dimen=middle,dotscale=2,fillloopadd=JHLEmphX2Y}
  \begin{pspicture}(-5.7,-5.7)(5.7,5.7)
    % JHLCommentXCentral domainY
    \rput(0,0){%
      \begin{pspicture}(5,5)
        % JHLCommentXReceive from West, East, North and SouthY
        \ReceiveData{(0,0.5)(0.5,4.5)}{\West}
        \ReceiveData{(4.5,0.5)(5,4.5)}{\East}
        \ReceiveData{(0.5,4.5)(4.5,5)}{\North}
        \ReceiveData{(0.5,0)(4.5,0.5)}{\South}
        % JHLCommentXSend area for West, East, North and SouthY
        \SendArea{(0.5,0.5)(1,4.5)}
        \SendArea{(4,0.5)(4.5,4.5)}
        \SendArea{(0.5,0.5)(4.5,1)}
        \SendArea{(0.5,4)(4.5,4.5)}
        % JHLCommentXCentral domainY
        \SubDomain{(5,5)}{(0.5,0.5)(4.5,4.5)}{solid}{\Central}
        % JHLCommentXRedraw overlapped linesY
        \psline(1,0.5)(1,4.5)
        \psline(4,0.5)(4,4.5)
        % JHLCommentXTwo crossesY
        \rput(1.5,4){\Cross}
        \rput(2,2){\Cross}
      \end{pspicture}}
    % JHLCommentXThe four neighborsY
    \rput(0,5.5){\Neighbor{N}{\North}}
    \rput{-90}(5.5,0){\Neighbor{E}{\East}}
    \rput{90}(-5.5,0){\Neighbor{W}{\West}}
    \rput{180}(0,-5.5){\Neighbor{S}{\South}}
  \end{pspicture}
\end{CenterExample}

% Bibliography
\begin{thebibliography}{99}
\bibitem{PostScript95} Adobe, Systems~Incorporated, \emph{PostScript Language
Reference Manual}, Addison-Wesley, 2~edition, 1995.

\bibitem{Bolek98} Piotr Bolek, \MP{} and patterns, \emph{\TUB}, Volume~19,
Number~3, pages 276--283, September 1998, \CTANref{mpattern}.

\bibitem{MLgraphTSI} Emmanuel Chailloux, Guy Cousineau and Asc\'ander
Su\'arez, Programmation fonctionnelle de graphismes pour la production
d'illustrations techniques, \emph{Technique et science informatique},
Volume~15, Number~7, pages 977--1007, 1996 (in french).

\bibitem{Deledicq97} Andr\'e Deledicq, \emph{Le monde des pavages}, ACL
\'Editions, 1997 (in french).

\bibitem{EsperetGirou98} Philippe Esperet and Denis Girou,
Coloriage du pavage dit de Truchet, Cahiers GUTenberg, Number~31,
pages 5--18, December~1998  (in french).

\bibitem{Girou94} Denis Girou, Pr\'esentation de PSTricks, \emph{Cahiers
GUTenberg}, Number~16, pages 21--70, February~1994 (in french).

\bibitem{LGC97} Michel Goossens, Sebastian Rahtz and Frank Mittelbach,
\emph{The \LaTeX{} Graphics Companion}, Addison-Wesley, 1997.

\bibitem{GS87} Branko Gr\"unbaum and Geoffrey Shephard, \emph{Tilings and
Patterns}, Freeman and Company, 1987.

\bibitem{Hoenig97} Alan Hoenig, \emph{\TeX{} Unbound: \LaTeX{} \& \TeX{}
Strategies, Fonts, Graphics, and More}, Oxford University Press, 1997.

\bibitem{XYpic} Kristoffer~H. Rose and Ross Moore, \XYpic. Pattern and Tile
extension, available from \CTAN, 1991-1998, \CTANref{xypic}.

\bibitem{LAAN96} Kees van der Laan, Paradigms: Just a little bit of PostScript,
\emph{MAPS}, Volume~17, pages 137--150, 1996.

\bibitem{LAAN97} Kees van der Laan, Tiling in PostScript and \MF{} -- Escher's
wink, \emph{MAPS}, Volume~19, Number~2, pages 39--67, 1997.

\bibitem{vanZandt93} Timothy van Zandt, PSTricks. PostScript macros for
Generic \TeX, available from \CTAN, 1993, \CTANref{pstricks}.

\bibitem{vanZandtGirou94} Timothy van Zandt and Denis Girou, Inside PSTricks,
\emph{\TUB}, Volume~15, Number~3, pages 239--246, September 1994.

\bibitem{Wang65} Hao Wang, Games, Logic and Computers, \emph{Scientific
American}, pages 98--106, November 1965.
\end{thebibliography}

\end{document}

