\listfiles
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{geometry,lmodern}
\usepackage{xcolor,array}
%\usepackage{pstricks}
\usepackage{listings}
%\usepackage{pst-pdf}

\makeatletter
\def\img{\@ifnextchar[{\img@i}{\img@i[0]}}
\def\img@i[#1]{\@ifnextchar[{\img@ii[#1]}{\img@ii[0][#1]}}
\def\img@ii[#1][#2]#3{\begin{center}
\ifnum#1>0 \includegraphics[scale=0.5]{images/#1}\fi\quad
\ifnum#2>0 \includegraphics[scale=0.5]{images/#2}\fi\quad
\includegraphics[scale=0.5]{images/#3}\end{center}}
\makeatletter

\definecolor{hellgelb}{rgb}{1,1,0.85}
\definecolor{colKeys}{rgb}{0,0,1}
\definecolor{colIdentifier}{rgb}{0,0,0}
\definecolor{colComments}{rgb}{1,0,0}
\definecolor{colString}{rgb}{0,0.5,0}
\lstset{
     language=PSTricks,%
     basicstyle=\footnotesize\ttfamily,%
     identifierstyle=\color{colIdentifier},%
     keywordstyle=\color{colKeys},%
     stringstyle=\color{colString},%
     stringstyle=\itshape\color{colComments},%
     commentstyle=\itshape\color{colComments},%
     columns=fixed,
     tabsize=4,%
     frame=single,%
     extendedchars=true,%
     showspaces=false,%
     showstringspaces=false,%
     numbers=left,%
     numberstyle=\tiny\ttfamily,%
     numbersep=1em,%
     breaklines=true,%
     breakindent=10pt,%
     backgroundcolor=\color{hellgelb},%
     breakautoindent=true,%
     captionpos=t,%
     xleftmargin=1em,%
}
\lstdefinestyle{syntax}{backgroundcolor=\color{blue!20},numbers=none,xleftmargin=0pt,xrightmargin=0pt,
    frame=single}

\usepackage{pst-fractal}
\let\myFV\fileversion

\usepackage{url}
\usepackage[bottom]{footmisc}
\usepackage{fancyhdr}
%\usepackage{abstract}
\pagestyle{fancy}
\usepackage{url}
\def\UrlFont{\small\ttfamily}
\makeatletter
\def\verbatim@font{\small\normalfont\ttfamily}
\makeatother
\lfoot{\small\ttfamily\jobname.tex}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\let\myPart\part
\renewcommand{\part}[1]{\clearpage\myPart{#1}}
\newcommand{\PS}{PostScript}
\newcommand\CMD[1]{\texttt{\textbackslash#1}}
\psset{subgriddiv=0,gridlabels=7pt,gridcolor=black!15}
\usepackage[pdfauthor={Herbert Voss},pdftitle={Fractals},linktocpage,colorlinks]{hyperref}
%

%
\begin{document}
\author{Herbert Voß\thanks{voss@perce.de}}
\date{\today}
\title{Fractals: pst-fractal v\myFV\\Documentation}

\maketitle%
\begin{abstract}
The well known \verb+pstricks+ package offers excellent macros to insert more or less complex 
graphics into a document. \verb+pstricks+ itself is the base for several other additional packages, 
which are mostly named \verb+pst-xxxx+, like \verb+pst-fractal+.

This version uses the extended keyval package \verb+xkeyval+, so be sure that you have installed
this package together with the spcecial one \verb+pst-xkey+ for PSTricks. The \verb+xkeyval+
package is available at \href{ftp://ftp.dante.de/pub/tex/macros/latex/contrib/xkeyval/}{CTAN:/macros/latex/contrib/xkeyval/}.
It is also important that after \verb+pst-fractal+ no package is loaded, which uses the old keyval interface.

The fractals are really big, which is the reason why this document is about 15 MByte
when you run it without using the external png-images.
\vspace*{2cm}
\end{abstract}%

\tableofcontents


\section{Sierpinski triangle}

The triangle must be given by three mandatory arguments:

\begin{lstlisting}[style=syntax]
\psSier[settings](x0,y0)(x1,y1)(x2,y2)
\end{lstlisting}

In difference to \verb|psfractal| it doesn't reserve any space, this is the
reason why it should be part of a \verb|pspicture| environment.

\img{1}
\begin{lstlisting}
\begin{pspicture}(5,5)
  \psSier(0,0)(2,5)(5,0)
\end{pspicture}
\end{lstlisting}



\section{Julia and Mandelbrot sets}

The syntax of the \verb+psfractal+ macro is simple
\begin{lstlisting}[style=syntax]
\psfractal[settings](x0,y0)(x1,y1)
\end{lstlisting}
All Arguments are optional, \verb+psfractal+ is the same as \verb+\psfractal(-1,-1)(1,1)+.

The Julia and Mandelbrot sets are a graphical representation of the following sequence

$x$ is the real and $y$ the imaginary part of the complex number $z$. $C(x,y)$ is a complex constant
and preset by $(0,0)$.
\begin{align}
z_{n+1}(x,y) &= (z_n(x,y))^2 +C(x,y)\\
\end{align}

\subsection{Julia sets}

A Julia set is given with

\begin{align}
z_{n+1}(x,y) &= (z_n(x,y))^2 +C(x,y)\\
z_0 	     &= (x_0;y_0)
\end{align}
$(x_0;y_0)$ is the starting value.


\img{2}
\begin{lstlisting}
\psfractal
\end{lstlisting}

\img{3}
\begin{lstlisting}
\psfractal[xWidth=4cm,yWidth=4cm, baseColor=white, dIter=20](-2,-2)(2,2)
\end{lstlisting}


\subsection{Mandelbrot sets}

A Mandelbrot set is given with

\begin{align}
z_{n+1}(x,y) &= (z_n(x,y))^2 +C(x,y)\\
z_0 	     &= (0;0)\\
C(x,y) 	     &= (x_0;y_0)
\end{align}

$(x_0;y_0)$ is the starting value.

\img{4}
\begin{lstlisting}
\psfractal[type=Mandel]
\end{lstlisting}


\img{5}
\begin{lstlisting}
\psfractal[type=Mandel, xWidth=6cm, yWidth=4.8cm, baseColor=white, dIter=10](-2,-1.2)(1,1.2)
\end{lstlisting}

\subsection{The options}


\subsection{\texttt{type}}
Can be of "`Julia"' (default) or "`Mandel"'.

\img[6]{7}
\begin{lstlisting}
\psfractal
\psfractal[type=Mandel]
\end{lstlisting}

\subsection{\texttt{baseColor}}
The color for the convergent part.

\img[8]{9}
\begin{lstlisting}
\psfractal[xWidth=4cm,yWidth=4cm,dIter=30](-2,-2)(2,2)
\psfractal[xWidth=4cm,yWidth=4cm,baseColor=yellow,dIter=30](-2,-2)(2,2)
\end{lstlisting}


\subsection{\texttt{xWidth} and \texttt{yWidth}}
These values define the physical width of the fractal.

\img{10}
\begin{lstlisting}
\psfractal[type=Mandel,xWidth=12.8cm,yWidth=10.8cm,dIter=5](-2.5,-1.3)(0.7,1.3)
\end{lstlisting}

\subsection{\texttt{cx} and \texttt{cy}}
Define the starting value for the complex constant number $C$.

\img[11]{12}
\begin{lstlisting}
\psset{xWidth=5cm,yWidth=5cm}
\psfractal[dIter=2](-2,-2)(2,2)
\psfractal[dIter=2,cx=-1.3,cy=0](-2,-2)(2,2)
\end{lstlisting}

\subsection{\texttt{dIter}}
The color is set by wavelength to RGB conversion of the iteration number, where
\verb+dIter+ is the step, predefined by 1. The wavelength is given by
the value of iter added by 400.

\img[13]{14}
\begin{lstlisting}
\psset{xWidth=5cm,yWidth=5cm}
\psfractal[dIter=30](-2,-2)(2,2)
\psfractal[dIter=10,cx=-1.3,cy=0](-2,-2)(2,2)
\end{lstlisting}

\subsection{\texttt{maxIter}}
\verb+maxIter+ is the number of the maximum iteration until it leaves the loop.
It is predefined by 255, but internally multiplied by \texttt{dIter}.

\img[15]{16}
\begin{lstlisting}
\psset{xWidth=5cm,yWidth=5cm}
\psfractal[maxIter=50,dIter=3](-2,-2)(2,2)
\psfractal[maxIter=30,cx=-1.3,cy=0](-2,-2)(2,2)
\end{lstlisting}

\subsection{\texttt{maxRadius}}
If the square of distance of $z_n$ to the origin of the complex coordinate system
is greater as \texttt{maxRadius} then the algorithm  leaves the loop
and sets the point. \texttt{maxRadius} should always be the square of the "`real"'
value, it is preset by 100.  

\img[17]{18}
\begin{lstlisting}
\psset{xWidth=5cm,yWidth=5cm}
\psfractal[maxRadius=30,dIter=10](-2,-2)(2,2)
\psfractal[maxRadius=30,dIter=30,cx=-1.3,cy=0](-2,-2)(2,2)
\end{lstlisting}

\subsection{\texttt{plotpoints}}
This option is only valid for the Sierpinski triangle and preset by 2000.

\img[19]{20}
\begin{lstlisting}
\begin{pspicture}(5,5)
  \psSier(0,0)(2.5,5)(5,0)
\end{pspicture}
\begin{pspicture}(5,5)
  \psSier[plotpoints=10000](0,0)(2.5,5)(5,0)
\end{pspicture}
\end{lstlisting}



\section{Phyllotaxis}
The beautiful arrangement of leaves in some plants, called phyllotaxis, 
obeys a number of subtle mathematical relationships. For instance, the florets 
in the head of a sunflower form two oppositely directed spirals: 55 of them clockwise 
and 34 counterclockwise. Surprisingly, these numbers are consecutive Fibonacci numbers. 
The Phyllotaxis is like a Lindenmayer system.

\begin{lstlisting}[style=syntax]
\psPhyllotaxis[settings](x,y)
\end{lstlisting}

The coordinates of the center are optional, if they are missing, then $(0,0)$
is assumed.


\img{21}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-3,-3)(3,3)
  \psPhyllotaxis
\end{pspicture}}
\end{lstlisting}



\img{22}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-3,-3)(4,4)
  \psPhyllotaxis(1,1)
\end{pspicture}}
\end{lstlisting}

\subsection{\texttt{angle}}

\img{23}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-2.5,-2.5)(2.5,2.5)
  \psPhyllotaxis[angle=99]
\end{pspicture}}
\end{lstlisting}

\subsection{\texttt{c}}
This is the length of one element in the unit pt.
\img{24}
\begin{lstlisting}
\psframebox{\begin{pspicture}(8,8)
  \psPhyllotaxis[c=7](4,4)
\end{pspicture}}
\end{lstlisting}

\img{25}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-3,-3)(3,3)
  \psPhyllotaxis[c=4,angle=111]
\end{pspicture}}
\end{lstlisting}

\subsection{\texttt{maxIter}}
This is the number for the iterations.

\img{26}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-3,-3)(3,3)
  \psPhyllotaxis[c=6,angle=111,maxIter=100]
\end{pspicture}}
\end{lstlisting}



\section{Fern}

\begin{lstlisting}[style=syntax]
\psFern[settings](x,y)
\end{lstlisting}

The coordinates of the starting point are optional, if they are missing, then $(0,0)$
is assumed.

\img{27}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-1,0)(1,4)
  \psFern
\end{pspicture}}
\end{lstlisting}

\img{28}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-1,0)(2,5)
  \psFern(1,1)
\end{pspicture}}
\end{lstlisting}

\img{29}
\begin{lstlisting}
\psframebox{\begin{pspicture}(-3,0)(3,11)
  \psFern[scale=3,maxIter=100000,linecolor=green]
\end{pspicture}}
\end{lstlisting}


\section{Koch flake}

\begin{lstlisting}[style=syntax]
\psKochflake[settings](x,y)
\end{lstlisting}

The coordinates of the starting point are optional, if they are missing, then $(0,0)$
is assumed. The origin is the lower left point of the flake, marked as red 
or black point
in the following example:
\clearpage

\img{30}
\begin{lstlisting}
\begin{pspicture}[showgrid=true](-2.4,-0.4)(5,5)
  \psKochflake[scale=10]
  \psdot[linecolor=red,dotstyle=*](0,0)
\end{pspicture}
\end{lstlisting}

\img{31}
\begin{lstlisting}
\begin{pspicture}(-0.4,-0.4)(12,4)
  \psset{fillcolor=lime,fillstyle=solid}
  \multido{\iA=0+1,\iB=0+2}{6}{%
    \psKochflake[angle=-30,scale=3,maxIter=\iA](\iB,2.5)\psdot*(\iB,2.5)
    \psKochflake[scale=3,maxIter=\iA](\iB,0)\psdot*(\iB,0)}
\end{pspicture}
\end{lstlisting}

Optional arguments are \verb+scale+, \verb+maxIter+ (iteration depth) and \verb+angle+
for the first rotation angle.


\section{Apollonius circles}

\begin{lstlisting}[style=syntax]
\psAppolonius[settings](x,y)
\end{lstlisting}

The coordinates of the starting point are optional, if they are missing, then $(0,0)$
is assumed. The origin is the center of the circle:

\img{32}
\begin{lstlisting}
\begin{pspicture}[showgrid=true](-4,-4)(4,4)
  \psAppolonius[Radius=4cm]
\end{pspicture}
\end{lstlisting}


\img{33}
\begin{lstlisting}
\begin{pspicture}(-5,-5)(5,5)
  \psAppolonius[Radius=5cm,Color]
\end{pspicture}
\end{lstlisting}


\section{Trees}

\begin{lstlisting}[style=syntax]
\psPTree[settings](x,y)
\psFArrow[settings](x,y){fraction}
\end{lstlisting}

The coordinates of the starting point are optional, if they are missing, then $(0,0)$
is assumed. The origin is the center of the lower line, shown in the following examples
by the dot. Special parameters are the width of the lower basic line for the tree and the
height and angle for the arrow and for both the color option. The color step is given by \verb+dIter+
and the depth by \verb+maxIter+. Valid optional arguments are

\medskip
\begin{center}
\begin{tabular}{@{}>{\ttfamily}lll@{}}
\emph{Name} & \emph{Meaning} & \emph{default}\\\hline
xWidth	    & first base width & 1cm\\
minWidth    & last base width  & 1pt\\
c	    & factor for unbalanced trees (0<c<1) & 0.5\\
Color       & colored tree     & fasle
\end{tabular}
\end{center}

\bigskip
\img{34}
\begin{lstlisting}
\begin{pspicture}[showgrid=true](-3,0)(3,4)
  \psPTree   
  \psdot*(0,0)
\end{pspicture}
\end{lstlisting}


\img{35}
\begin{lstlisting}
\begin{pspicture}[showgrid=true](-6,0)(6,7)
  \psPTree[xWidth=1.75cm,Color=true]
  \psdot*[linecolor=white](0,0)
\end{pspicture}
\end{lstlisting}


\img{36}
\begin{lstlisting}
\begin{pspicture}(-7,-1)(6,8)
  \psPTree[xWidth=1.75cm,c=0.35]
\end{pspicture}
\end{lstlisting}

\img{37}
\begin{lstlisting}
\begin{pspicture}(-5,-1)(7,8)
  \psPTree[xWidth=1.75cm,Color=true,c=0.65]
\end{pspicture}
\end{lstlisting}



\img[38][39]{40}
\begin{lstlisting}
\begin{pspicture}[showgrid=true](-1,0)(1,3)
  \psFArrow{0.5}
\end{pspicture}
\quad
\begin{pspicture}[showgrid=true](-2,0)(2,3)
  \psFArrow{0.6}
\end{pspicture}
\quad
\begin{pspicture*}[showgrid=true](-3,0)(3,3.5)
  \psFArrow[linewidth=3pt]{0.65}
\end{pspicture*}
\end{lstlisting}


\img[41][42]{43}
\begin{lstlisting}
\begin{pspicture}(-1,0)(1,3)
  \psFArrow[Color]{0.5}
\end{pspicture}
\quad
\begin{pspicture}(-2,0)(2,3)
  \psFArrow[Color]{0.6}
\end{pspicture}
\quad
\begin{pspicture*}(-3,0)(3,3.5)
  \psFArrow[Color]{0.65}
\end{pspicture*}
\end{lstlisting}


\img[0][44]{45}
\begin{lstlisting}
\begin{pspicture}(-3,-3)(2,3)
  \psFArrow[Color]{0.6}
  \psFArrow[angle=90,Color]{0.6}
\end{pspicture}
\quad
\begin{pspicture*}(-4,-3)(3,3)
  \psFArrow[Color]{0.7}
  \psFArrow[angle=90,Color]{0.7}
\end{pspicture*}
\end{lstlisting}

\section{PDF output}

\verb|pst-fractal| is based on the popular \verb|pstricks| 
package and writes pure \PS code\cite{PostScript}, so it is not 
possible to run \TeX{} files  with pdf\LaTeX{} when there are 
pstricks macros in the document. If you still need a PDF output use one of the following possibilities:
\begin{itemize}
\item package \verb|pdftricks.sty|\cite{pdftricks}
\item the for Linux free available program VTeX/Lnx\footnote{\url{http://www.micropress-inc.com/linux/}}
\item build the PDF with \verb|ps2pdf| (\verb|dvi|$\rightarrow$\verb|ps|$\rightarrow$\verb|pdf|)
\item use the \verb|pst-pdf| package.\footnote{\url{http://www.ctan.org/CTAN/macros/latex/contrib/pst-pdf/}}
\end{itemize}

You do not need to load \verb|pstricks.sty|, it will be done by \verb|pst-fractal| by default.

\section{FAQ}
\begin{itemize}
\item The fractal is not correct placed.

Be sure that you view your output with a dvi viewer which can show PostScript code, like
kdvi but not xdvi. It is better to run \verb|dvips| and then view the ps-file with \verb|gv|.
\item Unknown PostScript command:

Be sure that you have the ''newest`` \verb|pstricks-add.tex| file
\begin{lstlisting}[style=syntax]
\def\fileversion{2.85}
\def\filedate{2007/04/01}
\end{lstlisting}
\end{itemize}



\section{Credits}

\nocite{*}
\bgroup
\raggedright
\bibliographystyle{plain}
\bibliography{pst-fractal-doc}
\egroup
\end{document}
