[pstricks] PSTricks book
Zbigniew Nitecki
zbigniew.nitecki at tufts.edu
Fri May 15 18:06:26 CEST 2009
I received two copies of your email, sent two hours apart. I think
the code was the same in both.
I find it easier to read this code when it is in the TeXShop editor as
source code, although I don't
have the necessary style files, etc. to compile it into a pdf. So I
copied the whole thing into a
tex file, and made some corrections---as well as many commented-out
comments and questions---there.
Attached is the "marked up" version. Sorry for the delay, and let me
know if I can help further.
Best,
Ziggy
Zbigniew Nitecki
Department of Mathematics
Tufts University
Medford, MA 02155
telephones:
Office (617)627-3843
Dept. (617)627-3234
Dept. fax (617)627-3966
http://www.tufts.edu/~znitecki/
>
> here it comes ...
>
> thanks
> Herbert
> \svnInfo $Id: ch11-Custom.tex 180 2008-09-20 08:27:54Z herbert $
>
> \CurrentIndexPackage{pstricks}
> %
> ---------------------------------------------------------------------------------------
> \chapter{Custom styles and objects}\label{chap:custom}
> %
> ---------------------------------------------------------------------------------------
> \PST\ allows to define own new styles\index{style} for assistance
> and new macros
> which allow arbitrary area borders\index{area border} for filling and
> \Index{clipping}.
>
> %
> ---------------------------------------------------------------------------------------
> \section{Custom styles}\label{sec:custom:anwenderstile}
> %
> ---------------------------------------------------------------------------------------
> If certain combinations of parameters (\aref{sec:parameter}) are
> often used
> repeatedly, one may define special styles for them.
>
> \begin{BDef}
> \Lmcs{newpsstyle}\Largb{name}\Largb{list of parameters} \qquad
> \Lmcs{addtopsstyle}\Largb{name}\Largb{list of parameters}
> \end{BDef}
>
> This new style can be passed on to a macro by using the keyword
> \Lkeyword{style}
> when passing the parameters. Another useful application can be found
> in
> chapter~\vref{sec:fill:transparenteFarben}.
>
>
> \ExtendExampleWidth{-3}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{newpsstyle}\xLcs{psframe}\xLcs{pscircle}}
> \newpsstyle{TransparentMagenta}{%
> fillstyle=vlines,hatchcolor=magenta,
> hatchwidth=0.1\pslinewidth,hatchsep=1\pslinewidth}
> \begin{pspicture}(3,3)
> \psframe[fillstyle=solid,fillcolor=cyan](0.75,0.75)(3,3)
> \pscircle[style=TransparentMagenta](1,1){1}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \clearpage
>
>
> %\ExtendExampleWidth{-3}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{newpsstyle}\xLcs{psframe}\xLcs{pscircle}}
> \newpsstyle{Fiber}{linewidth=2pt}
> \begin{pspicture}(4,5)
> \psline[style=Fiber](0,0)(4,1)
> \addtopsstyle{Fiber}{linecolor=green}
> \psline[style=Fiber](0,1)(4,2)
> \addtopsstyle{Fiber}{linestyle=dotted}
> \psline[style=Fiber](0,2)(4,3)
> \addtopsstyle{Fiber}{}
> \psline[style=Fiber](0,3)(4,4)
> \addtopsstyle{Fibber}{linecolor=red}
> \psline[style=Fibber](0,4)(4,5)
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
>
> %
> ---------------------------------------------------------------------------------------
> \section{Custom objects}\label{sec:custom:newobject}
> %
> ---------------------------------------------------------------------------------------
> The styles described in the previous section may also be assigned to
> a special
> macro, which makes the application even easier. In the example below
> the new
> macro \verb+\dashedV+ is assigned a special style; the macro is
> based on the
> object \Lmcs{psline}.
>
> \begin{BDef}
> \Lmcs{newpsobject}\Largb{name}\Largb{name of object}\Largb{list of
> parameters}
> \end{BDef}
>
> %\ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}
> \newpsobject{LineA}{psline}{linewidth=1.5pt}
> \newpsobject{LineB}{LineA}{linestyle=dashed,
> dash=3pt 1.5pt}
> \newpsobject{LineC}{LineB}{dash=5pt 2pt}
> \newpsobject{LineD}{LineB}{dash=5pt 1pt 1pt 1pt}
> \newpsobject{LineE}{LineB}{dash=2pt 1pt}}
> \begin{Example}{\xLcs{newpsobject}\xLenv{pspicture}
> \xLkeyword{linecolor}\xLkeyword{dash}}
> \begin{pspicture}[showgrid=true](4,4)
> \LineA(0,0)(4,0)\LineB(0,1)(4,1)\LineC(0,2)(4,2)
> \LineD(0,3)(4,3)\LineE(0,4)(4,4)
> \end{pspicture}
> \end{Example}
>
> %
> ---------------------------------------------------------------------------------------
> \section{\nxLcs{pscustom}}\label{sec:pscustom}
> %
> ---------------------------------------------------------------------------------------
> \PST\ offers many ways of creating graphical objects. Nevertheless
> cases may
> occur where none of the existing macros satisfies one's needs. In
> all these
> cases \Lmcs{pscustom} can be of great help; the starred version
> fills the
> background with the current line colour as usual.
>
> \begin{BDef}
> \LmcsStar{pscustom}\OptArgs\Largb{arbitrary code}\\
> %\Lmcs{pscustom*}\OptArgs\Largb{arbitrary code}
> \end{BDef}
>
> \clearpage
>
>
> \Lcs{pscustom} expects that an arbitrary closed path\index{path!
> closed} is created through
> \Index{polylines} or \Index{polycurves} of whatever form.
> \Lcs{pscustom} starts
> a new path; the last closing braces terminates it.
> The closed path may then be filled or tiled arbitrarily with a
> \Index{colour} or
> \Index{pattern} through the filling function. One does not
> necessarily have to
> create line or curve segments which connect to each other. Usually
> they are
> automatically amended by \Lcs{pscustom} with lines to result in a
> closed
> polycurve.
>
> \index{tiling}\index{PostScript!macros}
> \PST\ provides special \PS\ commands which are used frequently by
> \PST\ itself
> as special \PST\ compatible versions. The advantage is that no
> additional use of
> the \Lcs[]{special} command is necessary. These additional macros can
> \textbf{only} be used in connection with \Lcs{pscustom}. All of them
> are
> described below.
>
> \index{PostScript!commands}
> The macros listed in this section influence the \PS\ output
> virtually without
> any control by \PST\ and should therefore only be used with at least
> basic
> knowledge of \PS\ as a programming language. Because of the \PS-
> specific code
> the current scale does not apply for the macros listed here. Only
> the common
> \PS\ unit \Index{bp} (\Index{big points}) or \Index{pt} is valid.
>
> \DANGER
> The macro \Lcs{pscustom} uses \Lcs{pstverb} ($\rightarrow$
> \vref{sec:pstverb})
> and \Lcs{pstunit} ($\rightarrow$\vref{sec:massstab}) which write
> \Lcs[]{special} into the \DVI\ file. The length of the argument is
> system-specific; problems may arise when putting many small
> polycurves together
> within \Lcs{pscustom} because these are all arguments of a single
> \Lcs[]{special} command.
>
> \DANGER
> All \PST\ objects which are defined through
> \Lcs{begin at SpecialObj}\ldots\Lcs{end at SpecialObj} may not appear
> within the
> argument of \Lcs{pscustom}. \PST\ will output a corresponding error
> message in
> this case.
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{Parameters}
> %
> ---------------------------------------------------------------------------------------
> Because \Lcs{pscustom} refers to a \textbf{single} closed
> path\index{path!closed} there can only be parameters referring to
> this path. The
> next example executes \Lcs{psline} outwith and within
> \Lcs{pscustom}. As can
> be seen easily from the coordinates, \Lcs{psline} within
> \Lcs{pscustom}
> should fill the lower triangle; this does not happen though because
> the
> so-called fill parameters \Lkeyword{linewidth},
> \Lkeyword{linecolor}, and
> \Lkeyword{fillstyle} have no effect within \Lcs{pscustom}. There are
> some
> exceptions, for example putting arrows. This will be pointed out
> separately in
> the examples below.
>
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example*}{\xLcs{psline}\xLcs{pscustom}\xLkeyword{linecolor}
> \xLkeyword{fillstyle}}
> \begin{pspicture}[showgrid=true](3,3)
> \psline[linewidth=2pt,linecolor=blue,fillstyle=vlines](0,1)(2,3)(0,3)
> \pscustom{\psline[linewidth=2pt,linecolor=blue,fillstyle=hlines](1,0)
> (3,2)(3,0)}
> \end{pspicture}\qquad
> \begin{pspicture}[showgrid=true](3,3)
> \psline[linewidth=2pt,linecolor=blue,fillstyle=vlines](0,1)(2,3)(0,3)
> \pscustom[linewidth=2pt,linecolor=blue,fillstyle=hlines]{\psline(1,0)
> (3,2)(3,0)}
> \end{pspicture}
> \end{Example*}
>
> As can be seen from the example above, the specification of
> parameters within
> \Lcs{pscustom} (left example) does not have any effect on the
> figure; in
> contrast to the correct example where the parameters are specified
> through the
> optional argument of \Lcs{pscustom}. It is therefore advisable to
> not use any
> parameters with the macros within \Lcs{pscustom} as a rule.
>
>
> The line styles \Lkeyval{dashed} and \Lkeyval{dotted} can be a
> problem because
> they do not know anything about an existing path at the beginning.
> In these
> cases \Lcs{pscustom} should be given the \Index{line style} listed in
> table~\vref{tab:linetype} as a parameter.
>
>
>
> \danger
> The following parameters are \textbf{not} available within the
> \Lcs{pscustom}
> macro -- \Lkeyword{shadow}, \Lkeyword{border}, \Lkeyword{doubleline},
> \Lkeyword{showpoints}.
> The parameters \Lkeyword{origin} and \Lkeyword{swapaxes} only affect
> \Lcs{pscustom} itself.
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{Open and closed curves}\label{subsec:Offene-und-
> geschlossene-Kurven}
> %
> ---------------------------------------------------------------------------------------
> \PST\ distinguishes between \Index{closed curve}s and \Index{open
> curve}s. As
> \Lcs{pscustom} is used itself to create closed polylines and
> polycurves, it
> makes little sense to use closed curves within \Lcs{pscustom}.
>
> The actual primary focus of \Lcs{pscustom} is connecting open lines
> and curves.
> In principle there will always be a direct line drawn from the end
> of the line/curve
> drawn last to the start of the next line or curve if it defines an
> \textbf{end
> arrow}. This can be seen clearly in the following example where in
> the first
> curve a connection from the first \Index{arc}\index{circle!arc} to
> the second
> one because it has an end arrow.
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{psline}\xLcs{pscustom}\xLkeyword{linecolor}
> \xLkeyword{showgrid}}
> \begin{pspicture}[showgrid=true](3,3)
> \psset{linewidth=1.5pt,arrowscale=2}
> \pscustom[linecolor=red]{%
> \psarc(0,0){2}{5}{85}\psarcn{->}(0,0){3}{85}{5}}
> \pscustom[linecolor=blue]{%
> \psarc(0,0){0.5}{5}{85}\psarcn{<-}(0,0){1.5}{85}{5}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> The above example assumes that the arrow is defined locally because
> it is only
> valid for a single polycurve here.
>
> \danger
> The macros \Lcs{psline}, \Lcs{pscurve}, and \Lcs{psbezier} start at
> the current
> point when their parameters are ,,incomplete``{}. It will always be
> set to the
> coordinate origin by \PST\ outwith \Lcs{pscustom} for \Lcs{psline} and
> \Lcs{psbezier}. In the following example this behaviour results in a
> polyline
> whereas without \Lcs{pscustom} two independent lines starting at the
> coordinate
> origin are drawn and nothing for \Lcs{pscurve} because if less than
> three
> coordinate pairs are specified here, no curve is drawn.
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{psline}\xLcs{pscustom}\xLkeyword{linecolor}
> \xLkeyword{linewidth}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \psline(1,3)\psline(2,0)
> \pscurve(2.5,2)(3,0)
> \psline(1,1)(1,0)}
> \end{pspicture}
> \end{Example}
>
>
> \danger
> The following graphical objects are \textbf{not} available within
> \Lcs{pscustom}
> -- \Lcs{psgrid}, \Lcs{psdots}, \Lcs{qline}, \Lcs{qdisk}.
> Closed lines or curves should \textbf{not} be part of
> \Lcs{pscustom}; unexpected
> side effects may occur.
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLkeyval{liftpen}}\label{subsec:custom:liftpen}
> %
> ---------------------------------------------------------------------------------------
> The parameter \Lkeyword{liftpen} is an exceptional tool to control the
> connection of several partial lines or curves within \Lcs{pscustom}.
>
> \begin{table}[htb]
> \caption{Meaning of the \texttt{liftpen} parameter}\label{tab:liftpen}
> \begin{tabularx}{\linewidth}{@{}lX@{}}
> \emph{value} & \emph{meaning}\\\hline
> $0$ & If a new polyline or polycurve does not start at the current
> point, a line
> is drawn from the current point to the starting point of the line or
> curve
> (default behaviour). If there is a line or curve with incomplete
> coordinates
> they are amended by the current point.\\
> $1$ & The current point is not taken into account when the
> specification of
> coordinates is incomplete; instead the coordinate origin is taken
> (only for
> \Lcs{psline} and \Lcs{psbezier}).\\
> $2$ & Single polylines or polycurves are treated as individual
> units; they do
> not use the current point as starting point (with incomplete
> coordinates) and no
> line is drawn from the current point to the starting point of the
> next object.\\
> \end{tabularx}
> \end{table}
>
> The next example is formally equivalent to the previous one; the
> difference is
> that the \Lcs{psline} macros now have \Lkeyword{liftpen}\=\relax1 as
> parameter
> and therefore the second line does not use the end point of the
> first curve as
> current point, but the coordinate origin. No \Lcs{pscurve} is drawn
> in this
> case because for this curve the incomplete coordinates (at least
> three pairs)
> are not amended with \Lkeyword{liftpen}\=\relax1. This affects the
> current
> point which remains at $(2,0)$; therefore the connecting line to the
> new
> starting point $(1,1)$ of the last \Lcs{psline} command starts from
> there.
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{psline}\xLcs{pscustom}\xLkeyword{linecolor}
> \xLkeyword{liftpen}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \psline(1,3)\psline[liftpen=1](2,0)
> \pscurve[liftpen=1](2.5,2)(3,0)
> \psline(1,1)(1,0)}
> \psline[linestyle=dashed](1,3)(2,0)
> \pscurve[linestyle=dashed](2,0)(2.5,2)(3,0)
> \psline[linestyle=dashed](3,0)(1,1)
> \end{pspicture}
> \end{Example}
>
> The same example with complete coordinates for \Lcs{pscurve} yields:-
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{psline}\xLcs{pscustom}\xLkeyword{linecolor}
> \xLkeyword{liftpen}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \psline(1,3)\psline[liftpen=1](2,0)
> \pscurve[liftpen=1](2,0)(2.5,2)(3,0)
> \psline(1,1)(1,0)}
> \psline[linestyle=dashed](1,3)(2,0)
> \end{pspicture}
> \end{Example}
>
> To illustrate this slightly complicated matter further, another
> example will be
> given which compares the behaviour for the different values of
> \Lkeyword{liftpen}.
>
> \setlength\ExampleWidth{\linewidth}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example*}{\xLcs{pscurve}\xLcs{pscustom}\xLcs[pst-plot]{psplot}
> \xLkeyword{linecolor}\xLkeyword{fillstyle}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[fillcolor=lightgray,fillstyle=solid]{%
> \psplot{0}{2.6}{x RadtoDeg 2 mul sin 2 add}
> \pscurve(3,1)(2,0)(1,1)(0,0)}
> \end{pspicture}\quad
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[fillcolor=lightgray,fillstyle=solid]{%
> \psplot{0}{2.6}{x RadtoDeg 2 mul sin 2 add}
> \pscurve[liftpen=1](3,1)(2,0)(1,1)(0,0)}
> \end{pspicture}\quad
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[fillcolor=lightgray,fillstyle=solid]{%
> \psplot{0}{2.6}{x RadtoDeg 2 mul sin 2 add}
> \pscurve[liftpen=2](3,1)(2,0)(1,1)(0,0)}
> \end{pspicture}
> \end{Example*}
> \NormalExampleWidth
>
>
> The left example (\Lkeyword{liftpen}\=\relax0) uses the end point of
> the first
> curve (\Lcs[pst-plot]{psplot}) as starting point of the next curve
> (\Lcs{pscurve}). The example in the middle (\Lkeyword{liftpen}\=
> \relax1) does
> \textbf{not} use the end point of the first curve (\Lcs[pst-plot]
> {psplot}) as
> the starting point of the next curve (\Lcs{pscurve}); a connecting
> line from the
> end point of the first curve to the starting point of the second
> curve is drawn
> however. The right example (\Lkeyword{liftpen}\=\relax2) neither the
> end point
> of the first curve (\Lcs[pst-plot]{psplot}) is used as the starting
> point of the
> second curve (\Lcs{pscurve}), nor a connecting line is drawn; two
> individual
> units are created.
>
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{moveto}}
> %
> ---------------------------------------------------------------------------------------
> Moves the \Index{current point}\index{point!current} to the new
> coordinates
> $(x,y)$ without drawing a line.
>
> \begin{BDef}
> \Lmcs{moveto}\Largra{x,y}
> \end{BDef}
>
> \ExtendExampleWidth{-3}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}
> \SpecialCoor}
> \begin{Example}{\xLcs{moveto}\xLcs{pscustom}\xLcs[pst-plot]{psplot}
> \xLkeyword{linecolor}\xLkeyword{linewidth}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \psplot{0}{3}{x 180 mul 1.57 div sin 2 add}
> \moveto(1.5,1.5)\pscurve(3,1)(2,0)(1,1)(0,0)}
> \psline[linestyle=dotted]{->}%
> (! 3 dup 180 mul 1.57 div sin 2 add)(1.5,1.5)
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \iffalse
> \bigskip
> \begin{leftbar}
> \begin{tabular}{l@{$\,\rightarrow\,$}l}
> \verb+\psplot+ & chapter~\vref{chap:pst-plot} \\
> \verb+\pscurve+ & section~\vref{sec:pscurve} \\
> \end{tabular}
> \end{leftbar}
> \fi
>
> \enlargethispage{3ex}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{newpath}}
> %
> ---------------------------------------------------------------------------------------
> Its use is completely identical to the \PS\ command \Lps{newpath}.
> The current
> path is deleted and a new one started; all information about the old
> path is
> lost. In the following example the first curve is not drawn for this
> reason.
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{pscurve}\xLcs{pscustom}\xLcs{newpath}
> \xLkeyword{linecolor}\xLkeyword{fillstyle}}
> \begin{pspicture}[showgrid=true](3,2)
> \pscustom[fillcolor=lightgray,fillstyle=solid]{%
> \psplot{0}{3}{x 180 mul 1.57 div sin 2 add}
> \newpath
> \pscurve(3,1)(2,0)(1,1)(0,0) }
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \clearpage
>
>
> \iffalse
> \begin{leftbar}
> \begin{tabular}{l@{$\,\rightarrow\,$}l}
> \verb+\psplot+ & chapter~\vref{chap:pst-plot} \\
> \verb+\pscurve+ & section~\vref{sec:pscurve} \\
> \end{tabular}
> \end{leftbar}
> \fi
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{closepath}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{closepath} is the counterpart to \Lcs{newpath} and its use is
> completely
> identical to the \PS\ command \Lps{closepath} as well. The current
> path is
> closed by connecting the starting point and the end point. When using
> \Lcs{moveto} many different parts may exist; they are all treated
> separately.
> The starting point is made the current point; after that all
> information about
> the old path is lost.
>
> The following example determines the starting point $(0,2)$ as the
> new current
> point after the application of \Lcs{closepath}; the next curve looks
> completely
> different because it uses this point as starting point.
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{closepath}\xLcs{pscustom}\xLcs[pst-plot]
> {psplot}\xLkeyword{linecolor}\xLkeyword{fillstyle}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[fillcolor=lightgray,
> fillstyle=solid]{%
> \psplot{0}{3}{x 180 mul 1.57 div sin 2 add}
> \closepath
> \pscurve(3,1)(2,0)(1,1)(0,0)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{stroke}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{stroke} makes it possible to pass special parameters to single
> parts within
> the \Lcs{pscustom} macro and to draw the previously created polyline
> or
> polycurve.
>
> \begin{BDef}
> \Lmcs{stroke}\OptArgs
> \end{BDef}
>
> \Lcs{stroke} does not replace the \Lcs{stroke} caused by \PST\
> itself in the
> \PS\ code at the end of a macro. This means that one has to choose
> at least a
> larger \Index{line width} to avoid overwriting. The next example
> illustrates how
> to create special lines from several colours in an easy manner.
>
> %\ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{stroke}\xLcs{pscustom}\xLcs[pst-plot]{psplot}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linecolor=white]{%
> \psplot{0}{3}{x 180 mul 1.57 div sin
> 1.5 mul 1.5 add}
> \stroke[linecolor=red,linewidth=7pt]
> \stroke[linecolor=blue,linewidth=4pt]
> \stroke[linecolor=green,linewidth=2pt]}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{fill}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{fill}, analogous to \Lcs{stroke}, makes it possible to pass
> special
> parameters to single parts within the \Lcs{pscustom} macro and to
> draw the
> polyline or polycurve created previously.
>
> \begin{BDef}
> \Lmcs{fill}\OptArgs
> \end{BDef}
>
> \Lcs{fill} does not replace the \Lcs{fill} caused by \PST\ in the \PS
> \ code at
> the end of a macro. As \Lcs{pscustom} fills the area with the
> current fill
> colour and fill style at the end anyway, possible applications of
> \Lcs{fill} are
> limited.
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{gsave} and \nxLcs{grestore}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{gsave} makes it possible to save the current \PS\ stack
> referring to the
> graphical output (path specifications, colour, line width,
> coordinate origin,
> etc.). \Lcs{grestore} restores all these values.
> %
> %\Lmcs{gsave}\\
> %\Lmcs{grestore}
> %
> The next example fills an area with \Lcs{gsave}/\Lcs{grestore}
> without making
> the borders visible through lines.
>
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{gsave}\xLcs{pscustom}\xLcs{grestore}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{%
> \psplot{0}{3}{x 180.0 mul 1.5 div
> sin 1.5 mul 1.5 add}
> \gsave
> \psline(3,3)(0,3)% is _not_ drawn
> \fill[fillcolor=lightgray,fillstyle=solid]
> \grestore }
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pst-plot}\SpecialCoor}
> \begin{Example}{\xLcs{gsave}\xLcs{pscustom}\xLcs{grestore}}
> \begin{pspicture}[showgrid=true](3,3)
> \pstVerb{/rad {180.0 mul 2 div} def}
> \pscustom[plotpoints=200]{%
> \psplot{0}{3}{x rad sin 1.5 add}
> \gsave
> \psline(! 3 dup rad sin 1.5 add)%
> (!3 dup rad sin neg 1.5 add)
> \psplot{3}{0}{x rad sin neg 1.5 add}
> \fill[fillcolor=lightgray,fillstyle=solid]
> \grestore
> \psplot[liftpen=2]{3}{0}{x rad sin neg 1.5 add}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \danger
> The macros \Lcs{gsave} and \Lcs{grestore} may only appear \textbf{in
> pairs}, but
> arbitrarily nested.
>
>
> \iffalse
> \medskip
> \begin{leftbar}
> \begin{tabular}{l@{$\,\rightarrow\,$}l}
> \verb+\psplot+ & chapter~\vref{chap:pst-plot} \\
> \verb+\pstVerb+ & section~\vref{sec:pstverb} \\
> \end{tabular}
> \end{leftbar}
> \fi
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{translate}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{translate} moves the coordinate origin to $(x,y)$ for all
> subsequent
> graphical operations.
>
> \begin{BDef}
> \Lmcs{translate}\Largra{$x,y$}
> \end{BDef}
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{translate}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \translate(0,1)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \translate(0,1)
> \psplot[liftpen=2]{0}{3}{x 180.0 mul 1.5 div sin}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{scale}}
> %
> ---------------------------------------------------------------------------------------
> In contrast with other length assignments, \Lmcs{scale} only takes
> dimensionless
> values which are internally assumed to have unit \verb+pt+.
>
> \begin{BDef}
> \Lmcs{scale}\Largb{value1 \OptArg{value2}}
> \end{BDef}
>
> Scales the \Lcs{pscustom} object with \Larg{value1} horizontally and
> with
> \Larg{value2} vertically; if no second value is specified, the
> object is scaled
> proportionally with \Larg{value1}. As can be seen from the example,
> negative
> values are possible as well; this corresponds to scaling and
> subsequent
> mirroring.
>
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{scale}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linewidth=1.5pt]{%
> \scale{1 0.5}
> \translate(0,1)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \translate(0,1)
> \scale{1 -0.5}
> \psplot[liftpen=2]{0}{3}{x 180.0 mul 1.5 div sin}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{rotate}}
> %
> ---------------------------------------------------------------------------------------
>
> \begin{BDef}
> \Lmcs{rotate}\Largb{angle in degrees}
> \end{BDef}
>
> Rotates the \Lcs{pscustom} object by the specified angle which has
> to be
> specified in degrees to be compliant with \PS.
>
>
> \clearpage
>
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{rotate}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}[showgrid=true](3,4)
> \pscustom[linewidth=1.5pt]{%
> \translate(0,1)
> \psplot[liftpen=2]{0}{3}{
> x 180.0 mul 1.5 div sin}
> \translate(0,1)
> \rotate{30}
> \psplot[liftpen=2]{0}{3}{
> x 180.0 mul 1.5 div sin}
> }
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{swapaxes}}
> %
> ---------------------------------------------------------------------------------------
> An example for this has been given already in
> chapter~\vref{chap:koordinatensystem}; only it was a parameter
> there. In any
> case only the $x$-$y$ axes are swapped, which is equivalent to
> \Lcs{rotate}\Largb{$-90$} \Lcs{scale}\Largb{$-1\mkern10mu 1$}.
> %
> %\begin{Xverbatim}{\xLcs{scale}\xLcs{rotate}}
> %\rotate{-90} \scale{-1 1}
> %\end{Xverbatim}
>
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{swapaxes}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}[showgrid=true](3,4)
> \pscustom[linewidth=1.5pt]{%
> \translate(0,1)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \translate(2,0)
> \swapaxes
> \psplot[liftpen=2]{0}{3}%
> {x 180.0 mul 1.5 div sin}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{msave} and \nxLcs{mrestore}}
> %
> ---------------------------------------------------------------------------------------
> These commands can be used to save and restore the currently valid
> coordinate
> system. In contrast to \Lcs{gsave} and \Lcs{grestore} all other
> parameters such
> as line type, line width, etc.\ are not affected by this.
>
>
> %
> %\Lmcs{msave}\\
> %\Lmcs{mrestore}
>
> %The current version of \PST\ contains a bug here; the following
> example will
> %only compile with the package \verb+pstricks-add+ without errors.
> The example draws the first sine function with the coordinate origin
> at
> \Lcs{translate}\Largrfix{0,1.5}; after that the state of the
> coordinate system
> is saved, a new origin is set with \Lcs{translate}\Largrfix{1,2},
> and another
> sine function is drawn. Based on the current origin \Largrfix{0,1.5} a
> \Lcs{translate}\Largrfix{1,2} corresponds to the absolute
> coordinates $(0,3.5)$.
> Afterwards the old state is restored with the macro \Lcs{mrestore};
> the
> coordinate origin is at \Largrfix{0,1.5} again and the following
> cosine function
> refers to it again.\index{coordinate origin}\index{coordinate system}
>
> \clearpage
>
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{msave}\xLcs{pscustom}\xLcs{mrestore}}
> \begin{pspicture}[showgrid=true](3,4)
> \pscustom[linewidth=1.5pt]{%
> \translate(0,1.5)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}%
> \msave
> \translate(1,2) \scale{1 0.5}
> \psplot[liftpen=2]{-1}{2}%
> {x 180.0 mul 1.5 div sin}
> \mrestore
> \psplot[liftpen=2]{0}{3}%
> {x 180.0 mul 0.5 div cos}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> \danger
> The macros \Lcs{msave} and \Lcs{mrestore} may only occur \textbf{in
> pairs}, but
> can be arbitrarily nested with themselves or with \Lcs{gsave} and
> \Lcs{grestore}. The nesting has to be balanced pairwise though.
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{openshadow}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{openshadow} creates a copy of the current path using the
> specified
> shadow-parameters. In contrast to \Lcs{closedshadow} the original
> path is not
> filled with a colour by default; it stays "`open"'. Filling it can
> be done by
> the user though.
>
> \begin{BDef}
> \Lmcs{openshadow}\OptArgs
> \end{BDef}
>
>
> %\ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{openshadow}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}[showgrid=true](3,4)
> \pscustom{%
> \translate(0,3)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \openshadow[shadowsize=6pt]}
> \pscustom[fillcolor=black!20,fillstyle=solid]{%
> \translate(0,1)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \openshadow[shadowsize=6pt]}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{closedshadow}}\label{subsubsec:Custom:closedshadow}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{closedshadow} creates a shadow of the ares surrounded by the
> current path
> as if it was a non-transparent environment.
>
> \begin{BDef}
> \Lmcs{closedshadow}\OptArgs
> \end{BDef}
>
> \clearpage
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{closedshadow}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}(3,2)
> \pscustom{\translate(0,1)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \closedshadow[shadowsize=6pt]}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> One has to keep in mind how the shadow is created. \PST\ simply
> copies the
> closed path, translates it corresponding to the specifications of
> \Lkeyword{shadowsize} and \Lkeyword{shadowangle}, fills it with
> \Lkeyword{shadowcolor}, and fills the old path again with
> \Lkeyword{fillcolor}, which
> is set to \LColor{white} by default. If the second filling is
> suppressed
> (corresponds to \Lcs{openshadow}), it results in the complete shadow
> copy shown
> in the following example, in contrast to the correct result next to
> it on the
> right.
>
>
> \SetPreambleCommands{\setlength\parindent{0pt}
> \usepackage{pstricks}
> \def\Hut{%
> \pscustom[fillstyle=none,shadowcolor=lightgray,fillcolor=red]{
> \psbezier(0,0)(1,1)(1,-1)(2,0)
> \psbezier(3,1)(1,1)(2,2)
> \closepath
> \closedshadow[shadowsize=10pt,fillcolor=white,shadowangle=30]}}}
> \begin{Escape}{\xLcs{closedshadow}\xLcs{pscustom}\xLcs{closepath}}
> \begin{pspicture}[showgrid=true](0,-0.25)(5,2)
> \makeatletter
> \bgroup
> \def\pst at closedshadow{%
> \addto at pscode{%
> gsave
> \psk at shadowsize \psk at shadowangle \tx at PtoC
> \tx at Shadow
> \pst at usecolor\psshadowcolor
> gsave fill grestore
> stroke grestore
> % gsave
> % \pst at usecolor\psfillcolor
> % gsave fill grestore
> % stroke
> % grestore%
> }}
> \Hut\egroup
> \makeatother
> \rput(2.5,0){\Hut}
> \end{pspicture}
> \end{Escape}
> \NormalExampleWidth
>
>
> When specifying a \Lkeyword{fillcolor} with the options of
> \Lcs{pscustom} which
> is different from \LColor{white}, one has to pass the right fill
> colour to the
> macro \Lcs{closedshadow} as well.
>
>
> \ExtendExampleWidth{-3}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{closedshadow}\xLcs{pscustom}\xLcs{psbezier}
> \xLkeyword{shadowsize}\xLkeyword{shadowangle}}
> \begin{pspicture}(0,-0.25)(2.5,2)
> \pscustom[shadowcolor=black!30,fillcolor=red]{%
> \psbezier(0,0)(1,1)(1,-1)(2,0)\psbezier(3,1)(1,1)(2,2)
> \closepath
> \closedshadow[shadowsize=10pt,shadowangle=30]}
> \end{pspicture}\\[10pt]
> \begin{pspicture}(0,-0.25)(2.5,2)
> \pscustom[shadowcolor=black!30,fillcolor=red]{%
> \psbezier(0,0)(1,1)(1,-1)(2,0)\psbezier(3,1)(1,1)(2,2)
> \closepath
> \closedshadow[shadowsize=10pt,shadowangle=30,
> fillcolor=white]}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{movepath}}
> %
> ---------------------------------------------------------------------------------------
> Translates the current path by \Largr{$dx,dy$}; after that, it is
> lost.
> \Lcs{gsave} and \Lcs{grestore} can be used to save and restore the
> original path
> however.
>
> \begin{BDef}
> \Lmcs{movepath}\Largr{$dx,dy$}
> \end{BDef}
>
>
> %\ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks,pst-plot}}
> \begin{Example}{\xLcs{movepath}\xLcs{pscustom}\xLcs{translate}}
> \begin{pspicture}[showgrid=true](4,3)
> \pscustom[fillcolor=black!10,
> fillstyle=solid]{%
> \translate(0,1.5)
> \psplot{0}{3}{x 180.0 mul 1.5 div sin}
> \movepath(1,0.5)}
> \psline[linestyle=dashed]{*->}(0,1.5)(1,2)
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{lineto}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{lineto} corresponds to \Lcs{psline}\Largr{\CAny} in principle,
> but always
> draws a line to \Largr{\CAny} starting from the current point (which
> therefore
> has to exist).
>
> \begin{BDef}
> \Lmcs{lineto}\Largr{\CAny}
> \end{BDef}
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{lineto}\xLcs{pscustom}}
> \begin{pspicture}[showgrid=true](2,2)
> \pscustom[linewidth=1.5pt]{%
> \psline(0,0)(1,2)\lineto(2,0)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{rlineto}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{rlineto} corresponds to \Lcs{lineto}\Largr{\CAny} in principle;
> only it is
> a relative translation from the current point.
>
> \begin{BDef}
> \Lmcs{rlineto}\Largr{$dx,dy$}
> \end{BDef}
>
> %\ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{rlineto}\xLcs{pscustom}}
> \begin{pspicture}[showgrid=true](2,2)
> \pscustom[linewidth=1.5pt]{%
> \psline(0,0)(1,2)\rlineto(1,-2)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{curveto}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{curveto} corresponds to \Lcs{psbezier}\Largrai\Largraii
> \Largraiii in
> principle; the current point is assumed to be the first one.
>
> \begin{BDef}
> \Lmcs{curveto}\Largrai\Largraii\Largraiii
> \end{BDef}
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{curveto}\xLcs{pscustom}\xLcs{moveto}}
> \begin{pspicture}[showgrid=true](3,2)
> \pscustom[linewidth=1.5pt]{%
> \moveto(0.5,0)\curveto(1,2)(2,0)(3,2)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{rcurveto}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{rcurveto} corresponds to \Lcs{curveto}\Largrai\Largraii
> \Largraiii in
> principle, only \textbf{all} are assumed to be coordinates relative
> to the
> current point.
>
>
> \begin{BDef}
> \Lmcs{rcurveto}\Largr{$dx_1,dy_1$}\Largr{$dx_2,dy_2$}
> \Largr{$dx_3,dy_3$}
> \end{BDef}
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{rcurveto}\xLcs{pscustom}\xLcs{moveto}}
> \begin{pspicture}[showgrid=true](3,2)
> \pscustom[linewidth=1.5pt]{%
> \moveto(0.5,0)
> \rcurveto(0.5,2)(1.5,0)(2.5,2)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{code}}\label{subsubsec:custom:code}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{code} inserts the \PS\ code given as parameter directly into
> the \PS\
> output. This macro is identical to \Lcs{addto at pscode} and should be
> preferred
> over using \Lcs[]{special} in \textbf{all} cases. Another example
> for \Lcs{code}
> can be found in section~\vref{subsec:pstplot:listplot}.
>
> \begin{BDef}
> \Lmcs{code}\Largb{PostScript code}
> \end{BDef}
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{code}\xLcs{pscustom}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{%
> \code{%
> newpath
> 20 20 moveto 0 50 rlineto
> 50 0 rlineto 0 -50 rlineto
> -50 0 rlineto closepath
> 2 setlinejoin 7.5 setlinewidth stroke}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{dim}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{dim} converts the current \PST\ unit to \verb+pt+, such that
> one can do
> calculations in the units specified by the \nxLenv{pspicture}
> environment, and
> puts the result on the \PS\ stack.
>
> \begin{BDef}
> \Lmcs{dim}\Largb{value unit}
> \end{BDef}
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{dim}\xLcs{pscustom}\xLcs{code}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{%
> \code{newpath}
> \dim{0cm}\dim{-2cm} \dim{2cm}\dim{0cm}
> \dim{0cm}\dim{2cm} \dim{0.5cm}\dim{0.5cm}
> \code{
> moveto rlineto rlineto rlineto closepath
> 2 setlinejoin 7.5 setlinewidth
> stroke}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{coor}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{coor} converts the specified coordinates from the \PST\ unit to
> \verb+pt+,
> such that one can do calculations in the units specified by the
> \nxLenv{pspicture} environment, and puts the result on the \PS\
> stack. Using
> \Lcs{coor} with several coordinates has a clear advantage over using
> \Lcs{dim}.
> \Lcs{coor} internally uses the macro \Lcs{pst@@getcoor}\Largb{\#1}
> which is
> called recursively when more than one coordinate pair is supplied.
>
> \begin{BDef}
> \Lmcs{coor}\Largrai\Largraii\ldots\Largran
> \end{BDef}
>
>
> \ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{coor}\xLcs{pscustom}\xLcs{code}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom[linecolor=red]{%
> \code{newpath}\coor(0,-2)(2,0)(0,2)(0.5,0.5)
> \code{ moveto rlineto rlineto rlineto
> closepath
> 2 setlinejoin 7.5 setlinewidth stroke}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{rcoor}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{rcoor} is in principle identical to \Lcs{coor} except that the
> \Index{coordinates} are put on the stack in reverse order
> (\Index{reverse
> coor}).
>
> \begin{BDef}
> \Lmcs{rcoor}\Largrai\Largraii\ldots\Largran
> \end{BDef}
>
> \clearpage
>
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{rccor}\xLcs{pscustom}\xLcs{code}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{%
> \code{newpath}\rcoor(0.5,0.5)(0,2)(2,0)(0,-2)
> \code{ moveto rlineto rlineto rlineto
> closepath
> 2 setlinejoin 7.5 setlinewidth stroke}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{file}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{file} inserts the contents of a file without any expansion as
> \PS\ code.
> Only comment lines starting with "`\verb+%+"' are ignored.
>
> \begin{BDef}
> \Lmcs{file}\Largb{filename}
> \end{BDef}
>
> The following example reads the contents of the file \Lfile[demo]
> {file.ps}
> previously written with \Lenv[]{filecontents} and executes the
> corresponding
> commands.
>
>
> \iffalse
> \begin{Xverbatim}{}
> % file "file.ps", demo for \file hv 2007-01-01
> newpath
> 20 20 moveto 0 50 rlineto 50 0 rlineto 0 -50 rlineto -50 0 rlineto
> closepath
> 2 setlinejoin 7.5 setlinewidth stroke
> % end
> \end{Xverbatim}
> %\lstinputlisting[caption={Contents of the file \texttt{file.ps}}]
> {file.ps}
> \fi
>
> \ExtendExampleWidth{-2}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}
> \begin{filecontents*}{file.ps}
> % file "file.ps", demo for \file hv 2007-01-01
> newpath 20 20 moveto 0 50 rlineto 50 0 rlineto
> 0 -50 rlineto -50 0 rlineto closepath
> 2 setlinejoin 7.5 setlinewidth stroke
> \end{filecontents*}}
> \begin{Example}{\xLcs{file}\xLcs{pscustom}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{\file{data/file.ps}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{arrows}}
> %
> ---------------------------------------------------------------------------------------
> \Lmcs{arrows} defines the type of the beginning and the end of the
> line or curve
> to insert.\index{PostScript!ArrowA}\index{PostScript!ArrowB}
>
>
> \begin{BDef}
> \Lmcs{arrows}\Largb{arrow type}
> \end{BDef}
>
> Internally the two \PS\ procedures \Lps{ArrowA} and \xLps{ArrowB}
> are used;
> parameters are to be given as follows:-
> %
> \begin{Xverbatim}{\xLps{ArrowA}\xLps{ArrowB}}
> x2 y2 x1 y1 ArrowA
> x2 y2 x1 y1 ArrowB
> \end{Xverbatim}
> %
> Both draw an arrow from \Largr{\Coord2} to \Largr{\Coord1}.
> \Lps{ArrowA} sets
> the current point to the end of the arrow and leaves \Largr{\Coord2}
> on the
> stack. \Lps{ArrowB} on the other hand does not change the current
> point, but
> leaves the four values \nxLps{x2 y2 x1' z1'} on the stack, where
> \Largr{$x_1^{\prime},y_1^{\prime}$} is the point where a line or
> curve connects.
>
> %\ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{pscustom}\xLcs{arrows}\xLcs{code}}
> \SpecialCoor
> \begin{pspicture}[showgrid=true](4,3)
> \pscustom[linewidth=1.5pt]{%
> \arrows{|->}
> \code{%
> 80 140 5 5 ArrowA % 80 140 on the stack
> 30 -30 110 75 ArrowB % 30 -30 105.41 68.986
> curveto}} % curve for three points
> \psline[linestyle=dashed]%
> (5pt,5pt)(80pt,140pt)(30pt,-30pt)(110pt,75pt)
> \uput[0](80pt,140pt){(80pt,140pt)}
> \uput[0](30pt,-30pt){(30pt,-30pt)}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
>
> %
> ---------------------------------------------------------------------------------------
> \subsection{\nxLcs{setcolor}}
> %
> ---------------------------------------------------------------------------------------
> \Lcs{setcolor} sets the current colour and uses \Lcs{pst at usecolor}
> internally.
> %The current version of \PST\ has a bug; this macro is only
> available when using
> %\verb+pstricks-add+.
>
> \begin{BDef}
> \Lmcs{setcolor}\Largb{colour name}
> \end{BDef}
>
> %\ExtendExampleWidth{-1}
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{pscustom}\xLcs{setcolor}\xLcs{code}\xLcs{rcoor}}
> \begin{pspicture}[showgrid=true](3,3)
> \pscustom{%
> \code{newpath}
> \rcoor(0.5,0.5)(0,2)(2,0)(0,-2)
> \setcolor{red}
> \code{ moveto rlineto rlineto rlineto
> closepath
> 2 setlinejoin 7.5 setlinewidth stroke}}
> \end{pspicture}
> \end{Example}
> \NormalExampleWidth
>
>
> \NormalExampleWidth
> \endinput
>
> \vfill
> \bgroup
> \SetPreambleCommands{\usepackage{pst-plot,pst-tree}
> \SpecialCoor
> \def\drawseg#1#2{% Michael Sharpe
> \pscustom{%
> \translate(#1,#2)
> \rotate{(\dirseg{#1}{#2})} % Vector in direction of field at
> x=#1,y=#2
> \psline(-.25,0)(.25,0)}}
> %
> \def\dirseg#1#2{-#2,#1}} % Default direction field ($y'=-x/y$)}
> \begin{Escape}{}
> \begin{pspicture}(-6,-6)(6,6)
> \psaxes{->}(0,0)(-5.5,-5.5)(5.5,5.5)
> \psset{arrows=->}
> \multido{\n=-5+1}{11}{%
> \multido{\N=-5+1}{11}{%
> \ifnum\N=0 \ifnum\n=0 \else\drawseg{\n}{\N}\fi
> \else\drawseg{\n}{\N}\fi}}
> \end{pspicture}
>
> \iffalse
> \def\dirseg#1#2{#2,#1} % Direction field example ($y'=x/y$)
> \begin{pspicture}(-6,-6)(6,6)
> \psaxes{<->}(0,0)(-6,-6)(6,6)
> \psset{arrows=->}
> \multido{\n=-5+1}{11}{%
> \multido{\N=-5+1}{11}{%
> \ifnum\N=0
> \ifnum\n=0
> \else
> \drawseg{\n}{\N}
> \fi
> \else
> \drawseg{\n}{\N}
> \fi}}
> \end{pspicture}
> \fi
> \end{Escape}
> \captionof{figure}{Vector field -- application of \nxLcs{translate}
> and \nxLcs{rotate} (\Author{Michael Sharpe})}
> \egroup
>
>
>
>
>
> \NormalExampleWidth
> \endinput
>
> \SetHiddenPreambleCommands{\setlength\parindent{0pt}}
> \SetPreambleCommands{\usepackage{pstricks}}
> \begin{Example}{\xLcs{}}
> \end{Example}
> <chap11.pdf>_______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20090515/1009b9dd/attachment-0002.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3D graphics.tex
Type: application/octet-stream
Size: 47810 bytes
Desc: not available
Url : http://tug.org/pipermail/pstricks/attachments/20090515/1009b9dd/attachment-0001.obj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20090515/1009b9dd/attachment-0003.html
More information about the PSTricks
mailing list