summaryrefslogtreecommitdiff
path: root/graphics/pdftricks/test.tex
blob: 06083b4931311999f1ef64fadd0e4de6091476d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
\documentclass{ltxguide}
\usepackage{txfonts,url}
\usepackage[shell,debug]%
  {pdftricks}

\begin{psinputs}
\usepackage{txfonts}
\usepackage{pstricks}
\usepackage{color}
\usepackage{pstcol}
\usepackage{pst-plot}
\usepackage{pst-tree}
\usepackage{pst-eps}
\usepackage{multido}
\usepackage{pst-node}
\usepackage{pst-eps}
\end{psinputs}

% 1. run pdfLaTeX
% 2. run script `pst2pdf' by invoking ./pst2pdf
% 3. second run of pdfLaTeX

\begin{document}

%\NoProcess[1-6]


\title{Trivial Experiments with psTricks manipulation}

\author{\bfseries Radhakrishnan CV and Rajagopal
           CV\\[-3pt]
       \small River Valley Technologies,
                       Trivandrum, India\\[-3pt]
       \small\url{http://www.river-valley.com}\\[6pt]
       \bfseries Antoine Chambert-Loir\\[-3pt]
       \small Ecole polytechnique, Palaiseau Cedex,
                       France\\[-3pt]
       \small \url{http://www.math.polytechnique.fr/~chambert}
}

\maketitle

\section{Objectives}

|psTricks| macros cannot be used with pdf\TeX, since the high level
PostScript language commands generated by the |psTricks| are unknown
to pdf\TeX. As such, a package \emph{viz.}, |pdfTricks.sty| has been
written to circumvent this limitation, so that the extensive
facilities offered by the powerful |psTricks| package can be made use
of in a pdf\TeX{} document. This is brought by making use of the shell
escape function available in the |web2c| \TeX{} compiler, while this
package is of no use to other commercial implementations.

Shell escape provides us the facility of stopping a \TeX{} run midway,
perform the functions that we do with a shell command, complete those
functions, return to the \TeX{} run and finish the job. Within a
package, this facility can be invoked by using 
|\write18{shell command}|. So if you use a line:
\begin{decl}
|write18 ls -l|
\end{decl}
\TeX{} will stop at the moment when it encounter the |\write18|
command, escapes to shell, executes |ls -l| command and return to the
compilation process.

\section{Shell escape}

In all the web2c \TeX{} implementations, shell escape is turned off by
default. You can either turn it on by changing the line in your
|texmf.cnf| (configuration file of your \TeX{} system) to:
\begin{decl}
|shell_escape = t|
\end{decl}
which will be `|f|' by default. You have to recreate all the formats
like |pdflatex.fmt| or whatever you might need. This is not a wise
step though, since it makes you open to the assault of Trojan macros
without your knowledge.

The more elegant way will be to invoke shell escape with a switch,
each time you run the compiler like:
\begin{decl}
|pdflatex -shell-escape <file name>|
\end{decl}
This eliminates the vulnerability to macros/packages written by
intelligent criminal minds.

\section{Usage}

The usage is very simple, as usual you have to load the package with a
package loading line in the preamble of your document:

\begin{decl}
|\usepackage{pdftricks}|
\end{decl}

All the packages that are needed for the compilation of the |pstricks|
code shall be enclosed within an environment |\begin{psinputs}| \dots
  |\end{psinputs}| in order to make it available to all the figure
documents during compilation. An example of this will look like
\begin{decl}
|\begin{psinputs}|\\
| \usepackage{pstricks}|\\
| \usepackage{color}   |\\
| \usepackage{pstcol}  |\\
| \usepackage{pst-plot}|\\
| \usepackage{pst-tree}|\\
| \usepackage{pst-eps} |\\
| \usepackage{multido} |\\
| \usepackage{pst-node}|\\
| \usepackage{pst-eps} |\\
| ... |\\
|\end{psinputs}|
\end{decl}

Each |pspicture| environment along with any macro code shall be
enclosed within an environment \emph{viz.}, |pdfpic|. This will enable
pdf\LaTeX{} to write external files like |fig1.tex|, |fig2.tex|,
\dots, depending on the number of |psTricks| figures you have included
in your document. |pdftricks| will intelligently find out whether your
pdf\TeX{} implementation has shell escape facility enabled or not.
Depending on this, there are two ways of approaching the problem which
are given in the succeeding sections.

\subsection{With shell escape}

With shell escape option invoked, one need not bother anything.  The
usual compilation with pdf\LaTeX{} will result in a |pdf| document
with all the figures appearing in the correct positions. pdf\TeX{}
will do the necessary job of writing all the |pstricks| code to self
standing external |*.tex| documents, escapes to shell, compiles the
|*.tex| document, converts to |*.eps|, translates to |*.pdf| and
includes in the location where the |pstricks| code appeared.

\subsection{Without shell escape}

A special shell script viz., |pst2pdf| is also provided. Now as the
second step, you have to execute this shell script, |pst2pdf| which
will compile all the newly written |fig1.tex|,\dots, and respective
|*.dvi| will be generated, which will be translated into respective
|*.eps| files and finally translated to |*.pdf| by calling |epstopdf|.
As a final step, you shall run pdf\LaTeX{} again, so that the |*.pdf|
figures will be included with the usual |\includegraphics| command
automatically in the locations wherever the |pstricks| code appeared.


See an example below:
\begin{verbatim}
\begin{pdfdisplay}
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\SpecialCoor
\begin{pspicture}(-6,-6)(6,6)
  \psaxes{<<->>}(0,0)(-6,-6)(6,6)
  \psset{arrows=->>}
  \multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
 \pstVerb{/x \ia\space def
    /y \ib\space def      
    y 0 eq                
      {/ValueTempA 0 def  
       /ValueTempB 0.5 def}
      {/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
       /ValueTempA 1 ValueTempZ div def        
       /ValueTempB x y ValueTempZ mul div def} 
      ifelse}                                  
 \psline(! x ValueTempA sub y ValueTempB sub)  
        (! x ValueTempA add y ValueTempB add)}}
\end{pspicture}
\end{pdfdisplay}
\end{verbatim}

This |psTricks| code will result in the following graphic:
\configure[pdfgraphic][color=red,rulesep=12pt,
                       linecolor=gray30,
                      linewidth=2pt]
\begin{pdfdisplay} 
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\def\transl#1#2{#1\space 72 2.54 div mul #2\space 72 2.54 div
     mul translate  0 0 moveto }
\newif\ifnotbothz
 \pspicture(-6,-6)(6,6)
 \psaxes{<->}(0,0)(-6,-6)(6,6)
 \multido{\n=-5+1}{11}{%
 \multido{\N=-5+1}{11}{%
 \notbothztrue%
 \ifnum\N=0 %
 \ifnum\n=0 \notbothzfalse\fi%
 \fi%
 \ifnotbothz%
 \psdot(0,0)%
 \pstverb{\transl{\n}{\N}\space
 \n\space neg \N\space
    atan rotate -9 0 moveto 18 0 rlineto stroke }
\fi}}
\endpspicture                      
\end{pdfdisplay}

The following are the steps in the sequential order:
\begin{decl}
1.~|latex <your document>|\\
2.~|pst2pdf|\\
3.~|latex <your document>|
\end{decl}

\section{Options and Hooks}

\begin{description}
  
\item[|shell|] This option will invoke the shell escape functions.

\item[|noshell|] This option will suppress the shell escape functions
  and will assume that there is no shell escape facility.

\item[|NoProcess|] A new command |\NoProcess| has been introduced in
  this version to facilitate the suppressing of pdf generation of
  those figures whose pdf's are already available. This might prove
  helpful when you have more figures to process and many of them are
  perfected and don't need recompilation and translation everytime you
  run pdf\LaTeX. The usage is:
\begin{decl}
|\NoProcess{<comma separated and/or hyphen separated ranges>}|
\end{decl}
If you have ten figures and if you want to suppress the processing of
the figure numbers 1, 2, 4 to 8 you can issue the command at the top
of the document as:
\begin{decl}
|\NoProcess{1,2,4-8}|
\end{decl}
\end{description}

\noindent There are few hooks to resize the graphic thus translated and
included.
\begin{decl}
|\configure[pdfgraphic][width=2in]|\\
|\configure[pdfgraphic][height=3in]|\\
|\configure[pdfgraphic][width=2in,height=3in]|
\end{decl}
the functionality is same as the |width| and |height| options as in
the |\includegraphics| command. But the graphic will be restricted to
aspect ratio.

\section{Limitations/Dependencies}

\begin{itemize}
\item Usage is limited to |web2c| \TeX{} implementations.
\item The shell escape commands used in this package are typical
  \textsc{Unix} commands and as such it best works in
  \textsc{Linux/Unix} flavours.
\item The package needs, |graphicx| and |keyval| packages; |epstopdf|,
  the Perl script that translates |eps| files into |pdf|.
\end{itemize}

\section{Licence}
The package is distributed under \textsc{gnu} General Public Licence.

\section{Examples}

Here are some examples of pstricks code and the figures generated by
pdf\LaTeX.
\subsection{Example 1}
\begin{verbatim}
\configure[pdfgraphic][width=2in,linecolor=red,background=gray10]
\begin{pdfdisplay}
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\SpecialCoor
\begin{pspicture}(-6,-6)(6,6)
  \psaxes{<<->>}(0,0)(-6,-6)(6,6)
  \psset{arrows=->>}
  \multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
 \pstVerb{/x \ia\space def
    /y \ib\space def
    y 0 eq
      {/ValueTempA 0 def
       /ValueTempB 0.5 def}
      {/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
       /ValueTempA 1 ValueTempZ div def
       /ValueTempB x y ValueTempZ mul div def}
      ifelse}
 \psline(! x ValueTempA sub y ValueTempB sub)
        (! x ValueTempA add y ValueTempB add)}}
\end{pspicture}
\end{pdfdisplay}
\end{verbatim}
\configure[pdfgraphic][width=.9\linewidth,linecolor=red,
                       rulesep=12pt,background=gray10,
                      linewidth=2pt]
\begin{pdfdisplay}
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\SpecialCoor
\begin{pspicture}(-6,-6)(6,6)
  \psaxes{<->}(0,0)(-6,-6)(6,6)
  \psset{arrows=->}
  \multido{\ia=-5+1}{11}{%
\multido{\ib=-5+1}{11}{%
 \pstVerb{/x \ia\space def
    /y \ib\space def
    y 0 eq
      {/ValueTempA 0 def
       /ValueTempB 0.5 def}
      {/ValueTempZ 2 1 x x mul y y mul div add sqrt mul def
       /ValueTempA 1 ValueTempZ div def
       /ValueTempB x y ValueTempZ mul div def}
      ifelse}
 \psline(! x ValueTempA sub y ValueTempB sub)
        (! x ValueTempA add y ValueTempB add)}}
\end{pspicture}
\end{pdfdisplay}

\subsection{Example 2}
\begin{verbatim}
\configure[pdfgraphic][linecolor=blue,background=gray10,width=4in]
\begin{pdfdisplay}
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\newcommand{\MyNode}[2]{%
  \Tr{\psshadowbox[fillstyle=solid,fillcolor=#1]{\tiny #2}}}
\newcommand{\NoeudXt}[1]{\MyNode{ForestGreen}{#1}}
\newcommand{\NoeudMotif}[1]{\MyNode{Navy}{\textcolor{white}{#1}}}
\psset{armB=5mm,angleA=90,angleB=-90,levelsep=2cm,treesep=5mm}
\renewcommand{\psedge}[2]{\ncangle{#2}{#1}}
\TeXtoEPS
\begin{pspicture}(-8cm,-9.5cm)(8cm,1cm)
\rput(0,0){\LARGE\textcolor{red}{Set of Motif widgets classes}}
\rput(0,-4.8){%
  \psframebox[fillstyle=solid,fillcolor=LemonChiffon,linearc=5mm,
             cornersize=absolute]
    {\pstree{\NoeudXt{Core}}
    {\pstree{\NoeudMotif{Primitive}}
            {\pstree{\NoeudMotif{Label}}
                    {\TC*}
             \NoeudMotif{Scrollbar}
             \NoeudMotif{List}
             \NoeudMotif{Text}
             \NoeudMotif{ArrowButton}}
     \pstree{\NoeudXt{Composite}}
            {\pstree{\NoeudXt{Constraint}}
                    {\pstree{\NoeudMotif{Manager}}
                            {\TC*}}}
     \pstree{\NoeudXt{Shell}}
            {\pstree{\NoeudXt{OverrideShell}}
                    {\NoeudMotif{MenuShell}}
             \pstree{\NoeudXt{WMShell}}
                    {\pstree{\NoeudXt{VendorShell}}
                            {\TC*}}}}}}
\rput(-2,-10){%
  \psshadowbox[fillstyle=solid,fillcolor=ForestGreen]{Core} Xt Class}
\rput(2,-10){%
  \psshadowbox[fillstyle=solid,fillcolor=Navy]{%
     \textcolor{white}{List}} Motif Class}
\end{pspicture}
\endTeXtoEPS
\end{pdfdisplay}
\end{verbatim}
\configure[pdfgraphic][linecolor=blue,
                       linewidth=2pt, rulesep=6pt,
                       background=gray10,scale=.8]
\begin{pdfdisplay}
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\newcommand{\MyNode}[2]{%
  \Tr{\psshadowbox[fillstyle=solid,fillcolor=#1]{\tiny #2}}}
\newcommand{\NoeudXt}[1]{\MyNode{ForestGreen}{#1}}
\newcommand{\NoeudMotif}[1]{\MyNode{Navy}{\textcolor{white}{#1}}}
\psset{armB=5mm,angleA=90,angleB=-90,levelsep=2cm,treesep=5mm}
\renewcommand{\psedge}[2]{\ncangle{#2}{#1}}
\TeXtoEPS
\begin{pspicture}(-8cm,-9.5cm)(8cm,1cm)
\rput(0,0){\LARGE\textcolor{red}{Set of Motif widgets classes}}
\rput(0,-4.8){%
  \psframebox[fillstyle=solid,fillcolor=LemonChiffon,linearc=5mm,
             cornersize=absolute]
    {\pstree{\NoeudXt{Core}}
    {\pstree{\NoeudMotif{Primitive}}
            {\pstree{\NoeudMotif{Label}}
                    {\TC*}
             \NoeudMotif{Scrollbar}
             \NoeudMotif{List}
             \NoeudMotif{Text}
             \NoeudMotif{ArrowButton}}
     \pstree{\NoeudXt{Composite}}
            {\pstree{\NoeudXt{Constraint}}
                    {\pstree{\NoeudMotif{Manager}}
                            {\TC*}}}
     \pstree{\NoeudXt{Shell}}
            {\pstree{\NoeudXt{OverrideShell}}
                    {\NoeudMotif{MenuShell}}
             \pstree{\NoeudXt{WMShell}}
                    {\pstree{\NoeudXt{VendorShell}}
                            {\TC*}}}}}}
\rput(-2,-10){%
  \psshadowbox[fillstyle=solid,fillcolor=ForestGreen]{Core} Xt Class}
\rput(2,-10){%
  \psshadowbox[fillstyle=solid,fillcolor=Navy]{%
     \textcolor{white}{List}} Motif Class}
\end{pspicture}
\endTeXtoEPS
\end{pdfdisplay}

\subsection{Example 3}
\begin{verbatim}
\configure[pdfgraphic][linecolor=black,background=gray30]
\begin{pdfdisplay}
\TeXtoEPS
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\psset{unit=.825cm}
\begin{pspicture}(10,8)
  \psset{fillstyle=solid,linestyle=none,linewidth=0}
  \psframe[fillcolor=lightblue](10,8)
  \pscircle[fillcolor=yellow](2,6){.8} % Sun
  {% Rays
   \psset{linecolor=yellow,linestyle=solid,linewidth=.3}
   \degrees[8]
   \multido{\i=1+1}{8}{\rput{\i}(2,6){\psline(1,0)(1.5,0)}}
  }%
  \pspolygon[fillcolor=green](6,0)(10,2)(10,0)% Grass
  \psdiamond[fillcolor=red,gangle=-45](8,6)(1.5,2.5)% Kite
  \rput{45}(8,6){\pnode(-2.5,0){Kitetail}}
  \rput{-10}(.8,1.5){\psdiamond[fillcolor=yellow](.6,.1)(.6,.3)}
  \rput{-80}(.8,1.5){\psdiamond[fillcolor=yellow](.6,.1)(.6,.3)}
  \pnode(.8,1.5){Tailend}
  \nccurve[fillstyle=none,angleA=270,angleB=125,ncurvB=.9,ncurvA=1.4,
           linestyle=dotted,dotstyle=square,linewidth=.25]{Kitetail}{Tailend}
  \newcommand{\bunting}{\pstriangle(.35,.35)}
  \psset{fillcolor=red,labelsep=.01}
  \naput[nrot=115,npos=.15]{\bunting}
  \nbput[nrot=25,npos=.15]{\bunting}
  \naput[nrot=75,npos=.4]{\bunting}
  \nbput[nrot=115,npos=.4]{\bunting}
  \naput[nrot=115,npos=.7]{\bunting}
  \nbput[nrot=25,npos=.7]{\bunting}
\end{pspicture}
\endTeXtoEPS
\end{pdfdisplay}
\end{verbatim}

\configure[pdfgraphic][width=\linewidth,
                       linewidth=2pt,
                       linecolor=gray30,                  
                       background=gray10,
                       rulesep=6pt]
\begin{pdfdisplay}
\TeXtoEPS
\definecolor{lightblue}{rgb}{0,0,.5}
\definecolor{Navy}{rgb}{0,0,0.5}
\definecolor{LemonChiffon}{rgb}{1,0.98,0.8}
\definecolor{ForestGreen}{rgb}{0.13,0.55,0.13}
\psset{unit=.825cm}
\begin{pspicture}(10,8)
  \psset{fillstyle=solid,linestyle=none,linewidth=0}
  \psframe[fillcolor=lightblue](10,8)
  \pscircle[fillcolor=yellow](2,6){.8} % Sun
  {% Rays
   \psset{linecolor=yellow,linestyle=solid,linewidth=.3}
   \degrees[8]
   \multido{\i=1+1}{8}{\rput{\i}(2,6){\psline(1,0)(1.5,0)}}
  }%
  \pspolygon[fillcolor=green](6,0)(10,2)(10,0)% Grass
  \psdiamond[fillcolor=red,gangle=-45](8,6)(1.5,2.5)% Kite
  \rput{45}(8,6){\pnode(-2.5,0){Kitetail}}
  \rput{-10}(.8,1.5){\psdiamond[fillcolor=yellow](.6,.1)(.6,.3)}
  \rput{-80}(.8,1.5){\psdiamond[fillcolor=yellow](.6,.1)(.6,.3)}
  \pnode(.8,1.5){Tailend}
  \nccurve[fillstyle=none,angleA=270,angleB=125,ncurvB=.9,ncurvA=1.4,
           linestyle=dotted,dotstyle=square,linewidth=.25]{Kitetail}{Tailend}
  \newcommand{\bunting}{\pstriangle(.35,.35)}
  \psset{fillcolor=red,labelsep=.01}
  \naput[nrot=115,npos=.15]{\bunting}
  \nbput[nrot=25,npos=.15]{\bunting}
  \naput[nrot=75,npos=.4]{\bunting}
  \nbput[nrot=115,npos=.4]{\bunting}
  \naput[nrot=115,npos=.7]{\bunting}
  \nbput[nrot=25,npos=.7]{\bunting}
\end{pspicture}
\endTeXtoEPS
\end{pdfdisplay}

\configure[pdfgraphic][width=\linewidth,
                       linewidth=2pt,
                       linecolor=gray30,                  
                       background=gray10,
                       rulesep=12pt]

\begin{pdfdisplay}

\definecolor{Pink}{rgb}{1.,0.75,0.8}
%  Flow diagram with the psmatrix environment\\[5mm]

  \psframebox[linearc=5mm,cornersize=absolute]{%
    \begin{psmatrix}[rowsep=0.5cm,colsep=0.8cm]
      \psovalbox[fillstyle=solid,fillcolor=yellow]{Begin} \\
      \psframebox{Initialisations} \\
      \psdiabox[fillstyle=solid,fillcolor=Pink]{Special} &
         \psframebox{Call to SP1} & \psframebox{Call to SP2} \\
      \psframebox{Action 1} \\
      \psframebox{Action 2} \\
      \psovalbox[fillstyle=solid,fillcolor=yellow]{End}
      % Links
      \ncline{1,1}{2,1}
      \ncline{2,1}{3,1}
      \ncline{3,1}{4,1}<{\textcolor{red}{No}}
      \ncline{4,1}{5,1}
      \ncline{5,1}{6,1}
      \ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
      \ncline{->}{3,2}{3,3}
      \ncbar[angleA=-90,armB=0,nodesepB=2.5mm]{->}{3,3}{4,1}
    \end{psmatrix}}
\end{pdfdisplay}

\begin{verbatim}
\begin{pdfdisplay}

\definecolor{Pink}{rgb}{1.,0.75,0.8}
%  Flow diagram with the psmatrix environment\\[5mm]

  \psframebox[linearc=5mm,cornersize=absolute]{%
    \begin{psmatrix}[rowsep=0.5cm,colsep=0.8cm]
      \psovalbox[fillstyle=solid,fillcolor=yellow]{Begin} \\
      \psframebox{Initialisations} \\
      \psdiabox[fillstyle=solid,fillcolor=Pink]{Special} &
         \psframebox{Call to SP1} & \psframebox{Call to SP2} \\
      \psframebox{Action 1} \\
      \psframebox{Action 2} \\
      \psovalbox[fillstyle=solid,fillcolor=yellow]{End}
      % Links
      \ncline{1,1}{2,1}
      \ncline{2,1}{3,1}
      \ncline{3,1}{4,1}<{\textcolor{red}{No}}
      \ncline{4,1}{5,1}
      \ncline{5,1}{6,1}
      \ncline{->}{3,1}{3,2}^{\textcolor{red}{Yes}}
      \ncline{->}{3,2}{3,3}
      \ncbar[angleA=-90,armB=0,nodesepB=2.5mm]{->}{3,3}{4,1}
    \end{psmatrix}}
\end{pdfdisplay}
\end{verbatim}
  
\end{document}