summaryrefslogtreecommitdiff
path: root/graphics/gastex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/gastex
Initial commit
Diffstat (limited to 'graphics/gastex')
-rw-r--r--graphics/gastex/README57
-rw-r--r--graphics/gastex/ex-beamer-gastex.tex107
-rw-r--r--graphics/gastex/ex-gastex.tex469
-rw-r--r--graphics/gastex/gastex.pro162
-rw-r--r--graphics/gastex/gastex.sty1959
5 files changed, 2754 insertions, 0 deletions
diff --git a/graphics/gastex/README b/graphics/gastex/README
new file mode 100644
index 0000000000..1f14e8cb6d
--- /dev/null
+++ b/graphics/gastex/README
@@ -0,0 +1,57 @@
+This is the README file for gastex package.
+
+GasTeX: Graphs and Automata Simplified in TeX
+
+GasTeX is a set of LaTeX macros which allow to draw very easily graphs,
+automata, nets, diagrams, etc... under the picture environment of LaTeX.
+
+Author:
+-------
+Paul Gastin <http://www.lsv.ens-cachan.fr/~gastin>
+
+Copyright: 2006 by Paul Gastin
+----------
+This program can be redistributed and/or modified under the terms
+of the LaTeX Project Public License Distributed from CTAN
+archives in directory macros/latex/base/lppl.txt.
+
+Installation:
+-------------
+In order to use gastex you only need two files:
+- gastex.sty which contains the definition of all the LaTeX macros (this file
+could be in your working folder or where other .sty files are).
+- gastex.pro which contains all the postscript procedures (this file could
+be in your working folder but it is best placed where the tex.pro file is).
+
+Usage: latex+dvips(+ps2pdf)
+------
+- Compile the source file with latex (not pdflatex) and generate the ps file
+with dvips. One may then use ps2pdf to get a pdf file.
+
+Remarks:
+--------
+- gastex mainly generates postscript code so the pictures cannot be seen with a
+dvi-viewer. One has to generate a ps file (latex+dvips) and view it with a
+ps-viewer. One can also generate a pdf file (latex+dvips+ps2pdf) and view
+it with a pdf-viewer.
+- gastex does not work with pdflatex since it produces postscript code
+which cannot be interpreted by a pdf viewer. Instead, one should generate
+the pdf file with latex+dvips+ps2pdf.
+
+Examples:
+---------
+- Several examples are provided on the gastex web page at
+http://www.lsv.ens-cachan.fr/~gastin/gastex/gastex.html
+- ex-gastex.tex contains some examples to learn gastex and to test your
+installation.
+- ex-beamer-gastex.tex shows how gastex may be used with beamer in order to
+produce very nice animated slides. You have to compile the file through
+latex-dvips-ps2pdf (not pdflatex).
+
+Documentation:
+--------------
+See http://www.lsv.ens-cachan.fr/~gastin/gastex/gastex.html
+The best is to learn with the examples (see above).
+Comments in the file gastex.sty provide documentation for all macros.
+
+Enjoy! \ No newline at end of file
diff --git a/graphics/gastex/ex-beamer-gastex.tex b/graphics/gastex/ex-beamer-gastex.tex
new file mode 100644
index 0000000000..d35ab955a4
--- /dev/null
+++ b/graphics/gastex/ex-beamer-gastex.tex
@@ -0,0 +1,107 @@
+% \documentclass[10pt,mathserif,handout]{beamer}
+\documentclass[10pt,mathserif,display]{beamer}
+\usepackage{gastex}
+\gasset{linewidth=0.21,AHdist=2.1,AHLength=2.25,AHlength=2.1}
+\gasset{ATdist=2.1,ATLength=2.25,ATlength=2.1}
+% \usepackage{beamerthemeEPIT}
+\usepackage{beamerthemeplain}
+
+\beamersetleftmargin{3mm}
+\beamersetrightmargin{3mm}
+\abovedisplayskip=1ex
+\belowdisplayskip=1ex
+\parskip=.5ex
+\parindent=0pt
+
+\newcommand{\Auto}{\mathcal{A}}
+\newcommand{\F}{\mathop{\mathsf{F}\vphantom{a}}\nolimits}
+\newcommand{\G}{\mathop{\mathsf{G}\vphantom{a}}\nolimits}
+\newcommand{\X}{\mathop{\mathsf{X}\vphantom{a}}\nolimits}
+\newcommand{\True}{\top}
+\newcommand{\False}{\bot}
+
+\newcommand{\Blue}[1]{\textcolor{blue}{#1}}
+\newcommand{\Red}[1]{\textcolor{red}{#1}}
+\newcommand{\Green}[1]{\textcolor{PineGreen}{#1}}
+
+\begin{document}
+
+
+%%%%%%%%%%%%%%%%%%%%%%
+\frame{
+ \frametitle{Automaton $\Auto_\varphi$}
+ \vspace{-7mm}
+ \begin{center}\scalebox{0.9}{
+ \begin{picture}(130,71)(-12,0)\nullfont
+% \put(-12,0){\framebox(130,71){}}
+ \gasset{Nadjust=w,Nadjustdist=2,Nh=8,fillcolor=White,Nfill=y,ilength=7}
+ {\only<7-| handout:0>{\gasset{fillcolor=yellow}}
+ \node[Nmarks=i](1)(10,45){$\varphi=\G(\neg p\vee\F q)$}}
+ \node(2)(10,25){$\neg p\vee\F q, \X\varphi$}\drawedge(1,2){}
+ \node(3)(10,05){$\neg p, \X\varphi$}\drawedge(2,3){}
+ \node(4)(40,25){$\F q, \X\varphi$}\drawedge(2,4){}
+ \node(5)(40,45){$q, \X\varphi$}\drawedge(4,5){}
+ \node(6)(40,05){$\X\F q, \X\varphi$}\drawedge(4,6){\Blue{$\F q$}}
+
+ \only<2->{
+ \only<2| handout:0>{\gasset{linecolor=Red}}
+ \drawedge[curvedepth=15](3,1){$\neg p$}
+ \drawedge[ELside=r,ELpos=35](5,1){$q$}
+ {\only<7-| handout:0>{\gasset{fillcolor=yellow}}
+ \node(7)(70,05){$\F q, {\only<3| handout:0>{\color{red}}\varphi}$}}
+ \drawedge(6,7){$\True$}
+ }
+ \only<3->{
+ \only<3| handout:0>{\gasset{linecolor=Red}}
+ \node(8)(70,25){$\F q,
+ {\only<3-4| handout:0>{\color{red}}\neg p\vee\F q},
+ {\only<3| handout:0>{\color{red}}\X\varphi}$}
+ \drawedge(7,8){}
+ }
+ \only<4->{
+ \only<4| handout:0>{\gasset{linecolor=Red}}
+ \node(9)(70,45){${\only<5| handout:0>{\color{red}}\F q},
+ {\only<4| handout:0>{\color{red}}\neg p},
+ \X\varphi$}
+ \drawedge[ELpos=55](8,4){}
+ \drawedge(8,9){}
+ }
+ \only<5->{
+ \node(10)(105,25){${\only<5| handout:0>{\color{red}}\X\F q},
+ \neg p, \X\varphi$}
+ \node(11)(40,65){${\only<5| handout:0>{\color{red}}q},
+ \neg p, \X\varphi$}
+ \only<5| handout:0>{\gasset{linecolor=Red}}
+ \drawedge(9,10){\Blue{$\F q$}}
+ \drawedge(9,11){}
+ }
+ \only<6->{
+ \only<6| handout:0>{\gasset{linecolor=Red}}
+ \drawedge(10,7){$\neg p$}
+ \drawedge[ELside=r](11,1){$\neg p\wedge q$}
+ }
+ \only<7->{\put(18,18){
+% \drawrect(58,33,100,53)
+ \gasset{loopdiam=5,Nw=7,Nh=7}
+ \gasset{fillcolor=yellow}
+ \node[Nmarks=i,ilength=5](A)(72,40){1}
+ \node(B)(92,40){2}
+ \drawedge[curvedepth=2,linecolor=blue](A,B){$\True$}
+ \drawedge[curvedepth=2](B,A){$q$}
+ \only<7>{\drawedge[curvedepth=8](B,A){$\neg p\wedge q$}}
+ \drawloop(A){$\neg p\vee q$}
+ \drawloop[linecolor=blue](B){$\True$}
+ \only<7>{\drawloop[ELpos=75,linecolor=blue,loopangle=0](B){$\neg p$}}
+ }}
+ \end{picture}}
+ \end{center}
+
+ \vspace{-2mm}
+ \uncover<2->{{\only<2>{\color{red}}
+ Transition = check litterals and move forward.}}
+
+ \uncover<8->{{\only<8>{\color{red}}
+ Simplification}}
+}
+
+\end{document}
diff --git a/graphics/gastex/ex-gastex.tex b/graphics/gastex/ex-gastex.tex
new file mode 100644
index 0000000000..42cbd1155f
--- /dev/null
+++ b/graphics/gastex/ex-gastex.tex
@@ -0,0 +1,469 @@
+%&latex
+\documentclass{article}
+\usepackage[usenames]{color}
+\usepackage{gastex}
+
+\begin{document}
+
+% Peterson automaton
+
+\begin{center}
+\begin{picture}(85,33)(-20,-28)
+% \put(-20,-28){\framebox(85,33){}}
+ \gasset{Nadjust=w,Nadjustdist=2,Nh=6,Nmr=1}
+ \node[Nmarks=i](A)(0,0){idle}
+ \node(B)(50,0){wait}
+ \node(C)(50,-20){wait}
+ \node[Nmarks=r](D)(0,-20){critical}
+
+ \drawedge(A,B){req1:=true}
+ \drawedge(B,C){turn:=2}
+ \drawedge[syo=-1,eyo=-1](C,D){turn=1?}
+ \drawedge[syo=1,eyo=1,ELside=r](C,D){req2=false?}
+ \drawedge(D,A){req1:=false}
+\end{picture}
+\end{center}
+
+% Petri Net and offsets
+
+\begin{center}
+\begin{picture}(110,50)(-25,-24)
+% \put(-25,-24){\framebox(110,50){}}
+ \node(A)(-20,-7){$\bullet \bullet$}
+ \node(B)(-20, 7){$\bullet$}
+ \node(C)( 20,-7){}
+ \node(D)( 20, 7){}
+ \gasset{Nw=.7,Nh=7,Nmr=0,fillgray=0} % black rectangle
+ \gasset{ExtNL=y,NLdist=1,NLangle=90} % external label above the node
+ \node(Ta)(0, 0){$a$}
+ \node(Tb)(0,-20){$b$}
+ \node(Tc)(0, 20){$c$}
+
+ \gasset{ELdistC=y,ELdist=0}
+ \drawedge[ELside=r,eyo=-1](A,Ta){\colorbox{white}{2}}\drawedge[eyo=1](B,Ta){}
+ \drawedge[syo=-1](Ta,C){}\drawedge[syo=1](Ta,D){}
+ {\gasset{curvedepth=4}\drawedge(C,Tb){}\drawedge(Tb,A){\colorbox{white}{2}}}
+ {\gasset{curvedepth=-4}\drawedge(D,Tc){}\drawedge[syo=1](Tc,B){}}
+ \drawbpedge[syo=-1,ELpos=70](Tc,-160,15,D,170,20){\colorbox{white}{3}}
+% offsets
+ \put(40,-15){\unitlength=1.2mm
+ \gasset{Nmr=0,Nfill=y,fillgray=0}
+ \node[Nw= 1,Nh=10](B)(0,20){}
+ \node[Nw= 1,Nh=10](C)(30,20){}
+ \node[Nw=10,Nh= 1](D)(15,0){}
+ \drawedge[syo=3,eyo=3,curvedepth=3](B,C){}
+ \drawedge[syo=1,eyo=1](B,C){}
+ \drawedge[syo=-1,eyo=-1](C,B){}
+ \drawbpedge[syo=4,eyo=4](B,165,30,C,15,30){}
+ \drawbpedge[syo=-3,exo=-3](B,0,10,D,90,10){}
+ \drawbpedge[syo=-3](C,180,10,D,90,10){}
+ \drawbpedge[sxo=3,eyo=-5](D,90,10,C,-90,10){}
+ \drawloop[sxo=-3,loopdiam=4,loopangle=-90](D){}
+ \drawloop[sxo= 3,loopdiam=4,loopangle=-90](D){}
+ }
+\end{picture}
+\end{center}
+
+% Diagram
+
+\begin{center}
+\begin{picture}(105,28)(-33,-3)
+% \put(-33,-3){\framebox(105,28){}}
+ \gasset{Nframe=n,Nadjust=w,Nh=6,Nmr=0}
+ \node(L)(0,20){$\mathcal{L}$}
+ \node(F)(30,20){$[F^V\to F]$}
+ \node(O1)( 20,0){$(\mathcal{P}(R)^V\to 2^{M\times\mathcal{P}(R)})$}
+ \node(O2)(-20,0){$(\mathcal{P}(R)^V\to 2^M)$}
+ \node(B1)( 60,0){$(\mathcal{P}(R)^V\to F)$}
+
+ \drawedge[ELpos=40](L,F){$[\![ -]\!]$}
+ \drawedge(L,O1){$X_F$}
+ \drawedge(F,O1){$\chi$}
+ \drawedge[ELside=r](L,O2){$X_M$}
+ \drawedge[ELpos=55](O1,B1){$\sqcup$}
+ \drawedge[ELside=r,ELpos=53](O1,O2){$\mathrm{Re}$}
+\end{picture}
+\end{center}
+
+% and more ...
+
+\begin{center}
+\begin{picture}(120,52)(-35,-37)
+% \put(-35,-37){\framebox(120,52){}}
+ \node[Nw=16,linecolor=Yellow,fillcolor=Yellow](A)(-20,0){initial}
+ \imark[iangle=200,linecolor=Peach](A)
+ \node[Nmr=0,Nw=14,fillgray=0.85,
+ dash={1}0](B)( 20,0){\textcolor{RedViolet}{final}}
+ \fmark[flength=10,fangle=-30,dash={3 1 1 1}0](B)
+ \node[Nadjust=wh,Nadjustdist=2,Nmr=3,Nmarks=r,linecolor=Green](C)(60,-20){$\left(
+ \begin{array}{ccc}
+ 2 & 1 & 0 \\
+ -1 & 0 & 1 \\
+ 0 & -1 & 2
+ \end{array}
+ \right)$}
+ \rmark[linecolor=Green,rdist=1.4](C)
+
+ \drawedge[curvedepth=5,linecolor=Red](A,B){\textcolor{Cyan}{curved}}
+ \drawedge[ELside=r,ELpos=35](A,B){straight}
+ \drawedge[curvedepth=-25,ELside=r,dash={1.5}0](A,B){far}
+ \drawloop[ELpos=75, loopangle=150, dash={0.2 0.5}0](A){loopCW}
+ \drawloop[loopCW=n,ELside=r,loopangle=30,dash={3 1.5}{1.5}](B){loopCCW}
+ \drawqbpedge[ELside=r,ELdist=0,dash={4 1 1 1}0](B,-90,C,180){qbpedge}
+ \drawloop[ELpos=70,loopangle=0](C){$b / 01$}
+ \drawloop[loopCW=n,ELpos=75,ELside=r,loopangle=-90,sxo=6](C){$a / 01$}
+ \drawloop[ELpos=75,loopangle=-90,sxo=-6](C){$b / 10 $}
+ \drawloop[loopangle=50](C){$b / 01$}
+ \drawloop[ELpos=75,loopangle=148](C){$b / 01$}
+\end{picture}
+\end{center}
+
+% Edges
+
+\begin{center}
+\begin{picture}(120,60)(-32,-14)
+% \put(-32,-14){\framebox(120,60){}}
+ \node(A)(10,0){}\node(B)(40,0){}
+ \drawedge(A,B){straight}
+ \drawedge[curvedepth=8](A,B){positive curve depth}
+ \drawedge[curvedepth=-8,ELside=r](A,B){negative curve depth}
+ \drawloop[loopangle=180](A){180}
+ \drawloop[loopangle=0](B){0}
+
+ \node(A)(-15,30){}\node(B)(15,30){}
+ \drawqbedge(A,-15,50,B){qbedge}
+ \drawbcedge(A,-20,10,B,20,10){bcedge}
+ \drawloop[loopangle=210](A){210}
+ \drawloop[loopangle=90,loopCW=n,ELside=r](B){90}
+
+ \node(A)(40,30){}\node(B)(70,30){}
+ \drawbpedge[ELpos=30,ELdist=0](A,45,20,B,225,20){bpedge}
+ \drawbpedge[ELpos=30,ELside=r](A,210,30,B,-30,30){30}
+ \drawbpedge[ELpos=70,ELside=r](A,210,30,B,-30,30){70}
+ \drawloop[loopdiam=5,loopangle=120,ELpos=60](A){smaller}
+ \drawloop[loopdiam=10,loopangle=30,ELpos=30](B){larger}
+\end{picture}
+\end{center}
+
+% Nodes, colors, etc...
+
+\begin{center}
+\begin{picture}(105,70)(-15,-65)
+% \put(-15,-65){\framebox(105,70){}}
+ \node[Nmarks=if](A)(0,0){1}
+ \node[Nw=15,Nh=6,Nmr=0](A)(25,0){rectangle}
+ \node[Nw=12,Nh=6,Nmr=3](A)(50,0){oval}
+
+ \node(B)(0,-15){Nadjust=n}
+ \node[Nadjust=w,Nmr=2](B)(25,-15){Nadjust=w}
+ \node[Nadjust=wh,Nmr=1](B)(50,-15){Nadjust=wh}
+
+ \gasset{Nadjust=w,Nadjustdist=3}
+ \node[Nmarks=i,iangle=210,ilength=5](C)(0,-30){imark}
+ \imark[iangle=150,ilength=10,linecolor=Red](C)
+ \node[Nmarks=f,fangle=30,flength=5,linecolor=Green](C)(25,-30){fmark}
+ \fmark[fangle=-30,flength=10,linecolor=Blue](C)
+ \node(C)(50,-30){rmark}
+ \rmark[linecolor=Red](C)\rmark[rdist=1.4,linecolor=Green](C)
+ \node[Nmarks=ifr](C)(75,-30){all}
+
+ \node(D)(0,-45){framed}
+ \node[Nframe=n,fillcolor=Yellow](D)(25,-45){filled}
+ \node[fillcolor=Yellow](D)(50,-45){both}
+ \node[fillcolor=Yellow,
+ linecolor=Green](D)(75,-45){\textcolor{RedViolet}{RedViolet}}
+
+ \node[linewidth=0.5](E)(0,-60){Thick}
+ \node[linewidth=1,linegray=0.8](E)(25,-60){Gray}
+ \node[dash={1.5}0](E)(50,-60){Dash}
+ \node[dash={4 1 1 1}0,linecolor=Red](E)(75,-60){More dash}
+\end{picture}
+\end{center}
+
+% Arrows
+
+\begin{center}\unitlength=0.85mm
+\begin{picture}(60,40)(-30,-17)
+% \put(-30,-17){\framebox(60,40){}}
+ \drawline[AHangle=30,AHLength=3,AHlength=0,
+ ATnb=1,ATangle=90,ATLength=2,ATlength=0](-15,20)(15,20)
+ \drawline[AHnb=2,ATnb=2](-15,15)(15,15)
+ \drawline[AHnb=2,AHangle=30,AHLength=3,AHlength=0,AHdist=1,
+ ATnb=2,ATangle=30,ATLength=3,ATlength=0,ATdist=1](-15,10)(15,10)
+ \drawline[AHnb=1,AHangle=30,AHLength=3,AHlength=1,
+ ATnb=1,ATangle=140,ATLength=3,ATlength=1.5](-15,5)(15,5)
+ \drawline[AHnb=2,AHangle=30,AHLength=3,AHlength=0,AHdist=1,
+ ATnb=2,ATangle=150,ATLength=3,ATlength=0,ATdist=1](-15,0)(15,0)
+ \node(A)(-15,-10){}\node(B)( 15,-10){}
+ \drawbpedge[AHnb=6,ATnb=6](A,60,25,B,240,25){}
+ \gasset{AHnb=1,AHangle=30,AHLength=3,AHlength=0,
+ ATnb=1,ATangle=30,ATLength=3,ATlength=0}
+ \drawloop[loopangle=180](A){}
+ \gasset{AHnb=3,AHangle=30,AHLength=3,AHlength=1.5,AHdist=1.8,
+ ATnb=3,ATangle=30,ATLength=3,ATlength=1.5,ATdist=1.8}
+ \drawloop[loopangle=0](B){}
+\end{picture}
+% \end{center}
+%
+% % Node label
+%
+% \begin{center}
+\begin{picture}(80,40)(-20,-20)
+% \put(-20,-20){\framebox(80,40){}}
+ \node[Nh=30,Nw=30,Nmr=15](D)(0,0){}
+ \gasset{ExtNL=y,NLdist=1,AHnb=0,ilength=-2}
+ \nodelabel[NLangle= 0](D){3} \imark[iangle= 0](D)
+ \nodelabel[NLangle= 30](D){2} \imark[iangle= 30](D)
+ \nodelabel[NLangle= 60](D){1} \imark[iangle= 60](D)
+ \nodelabel[NLangle= 90](D){12} \imark[iangle= 90](D)
+ \nodelabel[NLangle=120](D){11} \imark[iangle=120](D)
+ \nodelabel[NLangle=150](D){10} \imark[iangle=150](D)
+ \nodelabel[NLangle=180](D){9} \imark[iangle=180](D)
+ \nodelabel[NLangle=210](D){8} \imark[iangle=210](D)
+ \nodelabel[NLangle=240](D){7} \imark[iangle=240](D)
+ \nodelabel[NLangle=270](D){6} \imark[iangle=270](D)
+ \nodelabel[NLangle=300](D){5} \imark[iangle=300](D)
+ \nodelabel[NLangle=330](D){4} \imark[iangle=330](D)
+
+ \node[Nh=30,Nw=30,Nmr=15](B)(40,0){}
+ \gasset{ExtNL=n,NLdist=13}
+ \nodelabel[NLangle= 0](B){3}
+ \nodelabel[NLangle= 30](B){2}
+ \nodelabel[NLangle= 60](B){1}
+ \nodelabel[NLangle= 90](B){12}
+ \nodelabel[NLangle=120](B){11}
+ \nodelabel[NLangle=150](B){10}
+ \nodelabel[NLangle=180](B){9}
+ \nodelabel[NLangle=210](B){8}
+ \nodelabel[NLangle=240](B){7}
+ \nodelabel[NLangle=270](B){6}
+ \nodelabel[NLangle=300](B){5}
+ \nodelabel[NLangle=330](B){4}
+\end{picture}
+\end{center}
+
+% Nodes whose shape is a regular polygon
+
+\begin{center}
+\begin{picture}(120,30)(0,0)
+% \put(0,0){\framebox(120,30){}}
+ \rpnode[polyangle=90,Nmarks=i,iangle=-90](A)(5,14)(3,5){A}
+ \rpnode[arcradius=2,Nmarks=r](B)(35,17)(6,10){B}
+ \nodelabel[ExtNL=y,NLangle=30,NLdist=0.5](B){B}
+ \nodelabel[ExtNL=y,NLangle=60,NLdist=0.5](B){B}
+ \rpnode[arcradius=2,polyangle=90](C)(70,12)(5,7){C}
+ \imark[iangle=198](C)\fmark[fangle=18](C)
+ \rpnode[Nmarks=fr,fangle=45](D)(105,15)(4,7){D}
+ \drawloop(A){$a$}
+ \drawloop[loopangle=90](C){$c$}
+ \drawloop[loopangle=-45](D){$d$}
+ \drawedge(A,B){$x$}
+ \drawbpedge(B,-30,30,C,140,30){$y$}
+ \drawqbpedge(C,37,D,83){$z$}
+ \drawedge[curvedepth=14,ELside=r](D,A){}
+\end{picture}
+\end{center}
+
+% polygons and closed curves
+
+\begin{center}
+\begin{picture}(120,40)(0,0)
+% \put(0,0){\framebox(120,40){}}
+ \put(3,3){
+ \unitlength=8mm
+ \drawpolygon[fillcolor=Green,Nframe=n,arcradius=.3](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
+ \drawpolygon(0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
+ \drawccurve[linecolor=Red](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
+ }
+ \put(55,20){
+ \unitlength=1.4mm
+ \drawpolygon[fillcolor=Green,Nframe=n,arcradius=2](-10,-10)(10,10)(-10,10)(10,-10)
+ \drawpolygon(-10,-10)(10,10)(-10,10)(10,-10)
+ \drawccurve[linecolor=Red](-10,-10)(10,10)(-10,10)(10,-10)
+ }
+ \put(100,19){
+ \unitlength=20mm
+ \drawccurve[fillcolor=Yellow,linecolor=Red](0,1)(0.59,-0.8)(-0.95,0.3)(0.95,0.3)(-0.59,-0.8)
+ \drawpolygon(0,1)(0.59,-0.8)(-0.95,0.3)(0.95,0.3)(-0.59,-0.8)
+ }
+\end{picture}
+\end{center}
+
+% curves
+
+\begin{center}
+\begin{picture}(120,40)(0,0)
+% \put(0,0){\framebox(120,40){}}
+ \put(2,3){
+ \unitlength=8mm
+ \drawline[AHnb=0](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
+ \drawcurve[linecolor=Red,AHnb=0](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
+ }
+ \put(55,16){
+ \unitlength=1.5mm
+ \drawline[AHnb=0](-10,-10)(10,10)(-10,10)(10,-10)
+ \drawcurve[linecolor=Red,ATnb=3,AHnb=4](-10,-10)(10,10)(-10,10)(10,-10)
+ }
+ \put(100,19){
+ \unitlength=20mm
+ \drawline[AHnb=0](0.95,0.3)(-0.59,-0.8)(0,1)(0.59,-0.8)(-0.95,0.3)
+ \drawcurve[linecolor=Red](0.95,0.3)(-0.59,-0.8)(0,1)(0.59,-0.8)(-0.95,0.3)
+ }
+\end{picture}
+\end{center}
+
+% Various macros
+
+\begin{center}
+\begin{picture}(120,60)(-60,-30)
+% \put(-60,-30){\framebox(120,60){}}
+ \drawline(-60,0)(60,0)
+ \drawline(0,-30)(0,30)
+ \drawrpolygon[polyangle=90,fillcolor=Blue](-9,5)(3,8)
+ \drawrpolygon(-9,22)(8,7)
+ \drawrpolygon(-9,22)(8,6)
+ \drawrpolygon(-9,22)(8,5)
+ \drawrpolygon[polyangle=18,arcradius=5](-27,7)(5,7)
+ \drawrpolygon[fillcolor=Green](-27,23)(4,7)
+ \put(-48,15){
+ \unitlength=14mm
+ \gasset{Nfill=y,fillcolor=Yellow,Nframe=y,arcradius=.1}
+ \drawpolygon(0,1)(0.59,-0.8)(-0.95,0.3)(0.95,0.3)(-0.59,-0.8)
+ }
+ \drawline[AHLength=4,AHlength=0,AHangle=30,linewidth=.8](5,25)(15,15)(5,15)(15,5)
+ \drawline[AHLength=4,AHlength=0,AHangle=30,linecolor=White](5,25)(15,15)(5,15)(15,5)
+ \drawline[arcradius=1](17,25)(27,15)(17,15)(27,5)
+ \drawline[linecolor=Red](30,10)(50,20)(25,25)(55,5)
+ \drawline[AHLength=4,AHlength=0,AHangle=30,linewidth=.3](10,28)(35,28)
+ \drawline[AHnb=0,linewidth=.9](10,28)(34.5,28)
+ \drawline[AHnb=0,linewidth=.2,linecolor=White](10,28)(34.5,28)
+ \drawcbezier[ATnb=1](-50,-5,-30,-5,-30,-25,-10,-25)
+ \drawcbezier[AHnb=0,dash={1.5}0](-50,-25,-30,-25,-30,-5,-10,-5)
+ \drawqbezier(31,-20,50,-20,50,-1)
+ \drawqbezier[AHnb=0,linecolor=Green](31,-20,31,-1,50,-1)
+ \drawcircle[Nfill=y,fillcolor=Yellow](40,-25,10)
+ \drawrect[Nfill=y,fillcolor=Yellow,dash={1.5}0](5,-5,25,-15)
+ \drawoval(15,-25,20,10,3)
+\end{picture}
+\end{center}
+
+% Tricks: multiput and variables
+
+\begin{center}
+ \unitlength=0.7mm
+\begin{picture}(60,46)(0,-3)
+% \put(0,-3){\framebox(60,46){}}
+ {\gasset{AHnb=0}
+ \drawline(0,0)(60,0)
+ \drawline(0,20)(60,20)
+ \drawline(0,40)(60,40)}
+ \gasset{Nw=1.5,Nh=1.5,Nframe=n,Nfill=y}
+ \multiput(0,0)(10,0){5}{%
+ \node(A)(0,0){}\node(B)(5,20){}
+ \drawedge(A,B){}
+ }
+ \multiput(10,20)(10,0){5}{%
+ \node(A)(0,0){}\node(B)(5,20){}
+ \drawedge(A,B){}
+ }
+\end{picture}
+ \qquad
+ \unitlength=1mm
+\begin{picture}(50,30)(-5,0)
+% \put(-5,0){\framebox(50,30){}}
+ \def\ax{5}\def\ay{5}\def\bx{35}\def\by{25}%
+ \node(a)(\ax,\ay){$a$}\node(b)(\bx,\by){$b$}
+ \drawedge(a,b){}
+ \drawloop[loopdiam=6,loopangle=180](a){}
+ \drawloop[loopdiam=6,loopangle=0](b){}
+
+ \def\ax{5}\def\ay{25}\def\bx{35}\def\by{5}%
+ \node(a)(\ax,\ay){$a$}\node(b)(\bx,\by){$b$}
+ \drawedge(a,b){}
+ \drawloop[loopdiam=6,loopangle=180](a){}
+ \drawloop[loopdiam=6,loopangle=0](b){}
+\end{picture}
+\end{center}
+
+% Compatibility with gastex 1.0
+
+\begin{center}\compatiblegastexun
+\begin{picture}(80,55)(-20,-15)
+\thinlines
+\put(-20,-15){\framebox(80,55){}}
+
+\letstate A=(0,0) \drawinitialstate(A){1}\drawfinalstate[b](A){}
+\letstate B=(20,0) \drawrepeatedstate(B){2}
+\letstate C=(40,0) \drawfinalstate(C){3}
+\letstate D=(0,20) \drawrepeatedstate(D){4}
+\letstate E=(20,18) \drawstate(E){5}
+\letstate[8,6] F=(40,20) \drawrepeatedstate(F){6}
+
+\drawloop[b](B){$A,a,\alpha$} \drawloop[l](D){$A,\varepsilon$}
+{ \setpsdash(1) \drawloop(E){$B,b,\beta$} }
+\drawloop[r](F){$B,\varepsilon$}
+
+\drawtrans[r](A,B){$D,d,\delta$} \drawtrans[r](B,C){$D,\varepsilon$}
+{ \settransdecal{1}
+ \drawtrans(C,F){$F,f,\varphi$} \drawtrans(F,C){$G,g,\gamma$} }
+\drawtrans(B,E){$\varepsilon$} \drawtrans(E,F){$E,\varepsilon$}
+{ \setprofcurve{0} \drawcurvedtrans[r](E,D){$F,\varepsilon$} }
+
+\drawcurvedtrans(A,D){$C,c,\gamma$}
+{ \setpsdash(3) \drawcurvedtrans(D,A){$C,\varepsilon$} }
+{ \setprofcurve{-15} \drawcurvedtrans[r](F,D){$G_1,g_1,\gamma_1$} }
+\end{picture}
+\end{center}
+
+\begin{center}\compatiblegastexun
+\unitlength=1mm
+\begin{picture}(90,30)(-5,-16)
+\thinlines
+\put(-5,-16){\framebox(90,30){}}
+
+\setvertexdiam{6}
+\letvertex A=(0,0) \drawcircledvertex(A){$a$}
+\letvertex B=(20,0) \drawvertex(B){$b$}
+\letvertex[9] C=(40,0) \drawcircledvertex(C){$c$}
+\letvertex D=(60,0) \drawcircledvertex(D){$d$}
+\letvertex E=(80,0) \drawcircledvertex(E){$e$}
+
+\drawundirectededge(A,B){7}
+\drawundirectededge(B,C){-11}
+\drawundirectededge(C,D){13}
+\drawundirectededge(D,E){2}
+
+\setprofcurve{10}
+\drawundirectedcurvededge(A,C){3}
+\drawundirectedcurvededge(C,E){8}
+\setprofcurve{-10}
+\drawundirectedcurvededge[r](B,D){-5}
+
+\drawundirectedloop[b](A){17}
+\end{picture}
+\end{center}
+
+% Compatibility with pspictpg
+\begin{center}\compatiblepspictpg
+\begin{picture}(80,80)(-40,-40)
+% \put(-40,-40){\framebox(80,80){}}
+ \drawvector(-40,0)(40,0)
+ \drawvector(0,-40)(0,40)
+ \drawline(-30,-30)(30,30)
+ \cbeziervector(-30,-20)(-30,0)(-10,0)(-10,20)
+ {\setpsdash(3)\cbezier(-30,20)(-30,0)(-10,0)(-10,-20)}
+ \qbeziervector(1,-20)(20,-20)(20,-1)
+ \qbezier(1,-20)(1,-1)(20,-1)
+ \drawcircle(10,30)(10)
+ \put(-20,-30){\circle{10}}
+ \put(25,5){\line(1,3){8}}
+ \put(25,5){\vector(1,2){8}}
+ \setpsgray{0.5}
+ \drawdisk(-30,30)(10)
+ \put(20,-30){\circle*{10}}
+\end{picture}
+\end{center}
+
+\end{document}
+
+
diff --git a/graphics/gastex/gastex.pro b/graphics/gastex/gastex.pro
new file mode 100644
index 0000000000..e2ae122440
--- /dev/null
+++ b/graphics/gastex/gastex.pro
@@ -0,0 +1,162 @@
+%!
+TeXDict begin
+/!BP{ 72 72.27 div dup scale } def /!smartarct { /!r exch def /!y2
+exch def /!x2 exch def /!y1 exch def /!x1 exch def currentpoint /!y0
+exch def /!x0 exch def /!d0 !y0 !y1 sub dup mul !x0 !x1 sub dup mul
+add sqrt def /!d2 !y2 !y1 sub dup mul !x2 !x1 sub dup mul add sqrt
+def !d0 !d2 add 0 gt { !d0 !d2 le { /!xp !x1 !x2 !x1 sub !d0 mul !d2
+div add def /!yp !y1 !y2 !y1 sub !d0 mul !d2 div add def /!d !yp !y0
+sub dup mul !xp !x0 sub dup mul add sqrt 2 div def } { /!xp !x1 !x0
+!x1 sub !d2 mul !d0 div add def /!yp !y1 !y0 !y1 sub !d2 mul !d0 div
+add def /!d !yp !y2 sub dup mul !xp !x2 sub dup mul add sqrt 2 div
+def } ifelse } { /!d 0 def } ifelse !d !r lt { /!r !d def } if !x1
+!y1 !x2 !y2 !r arct } def /!psarrow { gsave 2 copy translate 3 -1 roll
+sub neg /!y exch def sub /!x exch def !x 0 eq !y 0 eq and {/!x 1 def}
+if !y !x atan rotate /L2 exch def /L1 exch def /ang exch def /dist
+exch def /nb exch def 1 1 nb { pop L2 0 eq { newpath L1 ang cos mul
+L1 ang sin mul 2 copy moveto 0 0 lineto neg lineto stroke } { newpath
+0 0 moveto L1 ang cos mul L1 ang sin mul 2 copy lineto L2 0 lineto
+neg lineto closepath fill } ifelse dist 0 translate } for grestore
+} def /!psvect { /y exch def /x exch def newpath 0 0 moveto x y lineto
+stroke 0 0 x y !psarrow x y 0 0 !psarrow } def /!pslines { /ra exch
+def /n exch def /yn exch def /xn exch def /yn_1 exch def /xn_1 exch
+def /x xn def /y yn def /xx xn_1 def /yy yn_1 def newpath xn yn moveto
+3 1 n { pop /x xx def /y yy def /yy exch def /xx exch def x y xx yy
+ra !smartarct } for xx yy lineto stroke xn_1 yn_1 xn yn !psarrow x
+y xx yy !psarrow } def /!psrectpath { /y1 exch def /x1 exch def /y0
+exch def /x0 exch def newpath x0 y0 moveto x1 y0 lineto x1 y1 lineto
+x0 y1 lineto closepath } def /!pscirclepath { newpath 0 360 arc closepath
+} def /!psovalpath { /rmax exch dup 0.1 le { pop 0.1 } if def /H exch
+2 div dup 0.1 le { pop 0.1 } if def /W exch 2 div dup 0.1 le { pop
+0.1 } if def /y exch def /x exch def H W le { /R H def }{ /R W def
+} ifelse rmax R le { /R rmax def } if newpath x y H add moveto x W
+add y H add x W add y R arct x W add y H sub x y H sub R arct x W sub
+y H sub x W sub y R arct x W sub y H add x y H add R arct closepath
+} def /!pspolygonpath { /ra exch def /n exch def dup n 2 mul 1 add
+1 roll 1 index n 2 mul 2 add 1 roll n 2 mul 1 sub index n 2 mul 1 sub
+index /yy exch def /xx exch def /y exch def /x exch def newpath xx
+x add 2 div yy y add 2 div moveto 1 1 n { pop /yy exch def /xx exch
+def x y x xx add 2 div y yy add 2 div ra !smartarct /x xx def /y yy
+def } for closepath } def /!psrpolygonpath { /rd exch def /ra exch
+def /a exch def /r exch def /n exch def /y exch def /x exch def /b
+360 n div def /c b def x y translate a rotate rd 0 ne { r rd b 2 div
+cos div sub r div dup scale } if /x1 r b cos mul def /y1 r b sin mul
+def newpath r x1 add 2 div y1 2 div moveto 1 1 n { pop /c c b add def
+/x2 r c cos mul def /y2 r c sin mul def x1 y1 x1 x2 add 2 div y1 y2
+add 2 div ra !smartarct /x1 x2 def /y1 y2 def } for closepath rd 0
+ne { r r rd b 2 div cos div sub div dup scale } if a neg rotate x neg
+y neg translate } def /!psccurvepath { /n exch def n 2 mul 1 sub index
+n 2 mul 1 sub index n 2 mul 1 sub index n 2 mul 1 sub index n 2 mul
+4 add array astore /coef exch def /alpha 3.5 def /px0 coef n 2 mul
+2 sub get def /py0 coef n 2 mul 1 sub get def /px1 coef 0 get def /py1
+coef 1 get def /px2 coef 2 get def /py2 coef 3 get def /d0 px1 px0
+sub dup mul py1 py0 sub dup mul add sqrt def /d2 px1 px2 sub dup mul
+py1 py2 sub dup mul add sqrt def /ppx d2 d0 div px0 px1 sub mul px1
+add def /ppy d2 d0 div py0 py1 sub mul py1 add def /d1 ppx px2 sub
+dup mul ppy py2 sub dup mul add sqrt def /qx d2 d1 div px2 ppx sub
+mul alpha div px1 add def /qy d2 d1 div py2 ppy sub mul alpha div py1
+add def newpath px1 py1 moveto 4 2 n 2 mul 2 add { /i exch def /px0
+px1 def /px1 px2 def /px2 coef i get def /py0 py1 def /py1 py2 def
+/py2 coef i 1 add get def /d0 d2 def /d2 px1 px2 sub dup mul py1 py2
+sub dup mul add sqrt def /ppx d0 d2 div px2 px1 sub mul px1 add def
+/ppy d0 d2 div py2 py1 sub mul py1 add def /d1 ppx px0 sub dup mul
+ppy py0 sub dup mul add sqrt def /rx d0 d1 div px0 ppx sub mul alpha
+div px1 add def /ry d0 d1 div py0 ppy sub mul alpha div py1 add def
+qx qy rx ry px1 py1 curveto /ppx d2 d0 div px0 px1 sub mul px1 add
+def /ppy d2 d0 div py0 py1 sub mul py1 add def /d1 ppx px2 sub dup
+mul ppy py2 sub dup mul add sqrt def /qx d2 d1 div px2 ppx sub mul
+alpha div px1 add def /qy d2 d1 div py2 ppy sub mul alpha div py1 add
+def } for closepath } def /!pscurve { /n exch def n 2 mul array astore
+/coef exch def /alpha 3.5 def /px1 coef 0 get def /py1 coef 1 get def
+/px2 coef 2 get def /py2 coef 3 get def /d2 px1 px2 sub dup mul py1
+py2 sub dup mul add sqrt def /qx px1 def /qy py1 def newpath px1 py1
+moveto 4 2 n 2 mul 2 sub { /i exch def /px0 px1 def /px1 px2 def /px2
+coef i get def /py0 py1 def /py1 py2 def /py2 coef i 1 add get def
+/d0 d2 def /d2 px1 px2 sub dup mul py1 py2 sub dup mul add sqrt def
+/ppx d0 d2 div px2 px1 sub mul px1 add def /ppy d0 d2 div py2 py1 sub
+mul py1 add def /d1 ppx px0 sub dup mul ppy py0 sub dup mul add sqrt
+def /rx d0 d1 div px0 ppx sub mul alpha div px1 add def /ry d0 d1 div
+py0 ppy sub mul alpha div py1 add def qx qy rx ry px1 py1 curveto /ppx
+d2 d0 div px0 px1 sub mul px1 add def /ppy d2 d0 div py0 py1 sub mul
+py1 add def /d1 ppx px2 sub dup mul ppy py2 sub dup mul add sqrt def
+/qx d2 d1 div px2 ppx sub mul alpha div px1 add def /qy d2 d1 div py2
+ppy sub mul alpha div py1 add def } for /px1 coef n 2 mul 2 sub get
+def /py1 coef n 2 mul 1 sub get def /rx px1 def /ry py1 def qx qy rx
+ry px1 py1 curveto stroke /px0 coef n 2 mul 6 sub get def /py0 coef
+n 2 mul 5 sub get def /px1 coef n 2 mul 4 sub get def /py1 coef n 2
+mul 3 sub get def /px2 coef n 2 mul 2 sub get def /py2 coef n 2 mul
+1 sub get def /d0 px1 px0 sub dup mul py1 py0 sub dup mul add sqrt
+def /d2 px1 px2 sub dup mul py1 py2 sub dup mul add sqrt def /ppx d2
+d0 div px0 px1 sub mul px1 add def /ppy d2 d0 div py0 py1 sub mul py1
+add def /d1 ppx px2 sub dup mul ppy py2 sub dup mul add sqrt def /qx
+d2 d1 div px2 ppx sub mul alpha div px1 add def /qy d2 d1 div py2 ppy
+sub mul alpha div py1 add def px1 py1 qx qy px2 py2 px2 py2 !ps_cbezier_arrow
+/px0 coef 0 get def /py0 coef 1 get def /px1 coef 2 get def /py1 coef
+3 get def /px2 coef 4 get def /py2 coef 5 get def /d0 px1 px0 sub dup
+mul py1 py0 sub dup mul add sqrt def /d2 px1 px2 sub dup mul py1 py2
+sub dup mul add sqrt def /ppx d0 d2 div px2 px1 sub mul px1 add def
+/ppy d0 d2 div py2 py1 sub mul py1 add def /d1 ppx px0 sub dup mul
+ppy py0 sub dup mul add sqrt def /rx d0 d1 div px0 ppx sub mul alpha
+div px1 add def /ry d0 d1 div py0 ppy sub mul alpha div py1 add def
+px1 py1 rx ry px0 py0 px0 py0 !ps_cbezier_arrow } def /!ps_cbezier
+{ /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def
+/x1 exch def /y0 exch def /x0 exch def newpath x0 y0 moveto x1 y1 x2
+y2 x3 y3 curveto stroke x0 y0 x1 y1 x2 y2 x3 y3 !ps_cbezier_arrow x3
+y3 x2 y2 x1 y1 x0 y0 !ps_cbezier_arrow } def /!ps_cbezier_arrow { /y3
+exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def /x1 exch
+def /y0 exch def /x0 exch def /xa x1 x2 sub 3 mul x3 x0 sub add def
+/xb x0 x1 sub x1 sub x2 add 3 mul def /xc x1 x0 sub 3 mul def /ya y1
+y2 sub 3 mul y3 y0 sub add def /yb y0 y1 sub y1 sub y2 add 3 mul def
+/yc y1 y0 sub 3 mul def /L2 exch def /L1 exch def /ang exch def /dist
+exch def /nb exch def L2 0 le { /L L1 ang cos mul 2 div def } { /L
+L2 def } ifelse /t4 1 def 1 1 nb { pop /x4 t4 !calculx def /y4 t4 !calculy
+def L 0 le { /dx t4 !calculdx def /dy t4 !calculdy def dx dup mul dy
+dup mul add sqrt dup 0 eq { /dx 1 def /dy 0 def pop 1 } if L1 exch
+div dup dx neg mul /xx exch def dy neg mul /yy exch def } { /t1 0 def
+/t2 t4 def 0 1 !max { pop /t t1 t2 add 2 div def t !calculx x4 sub
+dup mul t !calculy y4 sub dup mul add sqrt L ge { /t1 t def } { /t2
+t def } ifelse } for /x6 t !calculx def /y6 t !calculy def L1 L div
+dup x6 x4 sub mul /xx exch def y6 y4 sub mul /yy exch def } ifelse
+/x5 x4 xx ang cos mul add yy ang sin mul sub def /y5 y4 xx ang sin
+mul add yy ang cos mul add def /x7 x4 xx ang cos mul add yy ang sin
+mul add def /y7 y4 xx ang sin mul sub yy ang cos mul add def L2 0 le
+{ newpath x5 y5 moveto x4 y4 lineto x7 y7 lineto stroke } { newpath
+x4 y4 moveto x5 y5 lineto x6 y6 lineto x7 y7 lineto closepath fill
+} ifelse /t1 0 def /t2 t4 def 0 1 !max { pop /t t1 t2 add 2 div def
+t !calculx x4 sub dup mul t !calculy y4 sub dup mul add sqrt dist ge
+{ /t1 t def } { /t2 t def } ifelse } for /t4 t def } for } def /!ps_qbezier
+{ /y3 exch def /x3 exch def /yy exch def /xx exch def /y0 exch def
+/x0 exch def /x1 xx 2 mul x0 add 3 div def /y1 yy 2 mul y0 add 3 div
+def /x2 xx 2 mul x3 add 3 div def /y2 yy 2 mul y3 add 3 div def x0
+y0 x1 y1 x2 y2 x3 y3 !ps_cbezier } def /!max 10 def /!ps_r_cbezier
+{ /y3 exch def /x3 exch def /y2 exch def /x2 exch def /y1 exch def
+/x1 exch def /y0 exch def /x0 exch def /xa x1 x2 sub 3 mul x3 x0 sub
+add def /xb x0 x1 sub x1 sub x2 add 3 mul def /xc x1 x0 sub 3 mul def
+/ya y1 y2 sub 3 mul y3 y0 sub add def /yb y0 y1 sub y1 sub y2 add 3
+mul def /yc y1 y0 sub 3 mul def /t1 0 def /t2 1 def 0 1 !max { pop
+/t t1 t2 add 2 div def t !calculx t !calculy path!a inufill { /t1 t
+def } { /t2 t def } ifelse } for /ta t def /t1 0 def /t2 1 def 0 1
+!max { pop /t t1 t2 add 2 div def t !calculx t !calculy path!b inufill
+{ /t2 t def } { /t1 t def } ifelse } for /tb t def ta !calculx ta !calculy
+ta !calculdx 3 div tb ta sub mul ta !calculx add ta !calculdy 3 div
+tb ta sub mul ta !calculy add tb !calculdx 3 div ta tb sub mul tb !calculx
+add tb !calculdy 3 div ta tb sub mul tb !calculy add tb !calculx tb
+!calculy !ps_cbezier } def /!calculx { dup dup xa mul xb add mul xc
+add mul x0 add } def /!calculy { dup dup ya mul yb add mul yc add mul
+y0 add } def /!calculdx { dup 3 xa mul mul 2 xb mul add mul xc add
+} def /!calculdy { dup 3 ya mul mul 2 yb mul add mul yc add } def /!node_mark
+{ /ma exch def /ml exch def /y exch def /x exch def /x1 x def /y1 y
+def /x2 x 500 ma cos mul add def /y2 y 500 ma sin mul add def 0 1 !max
+{ pop /x x1 x2 add 2 div def /y y1 y2 add 2 div def x y path!a inufill
+{ /x1 x def /y1 y def } { /x2 x def /y2 y def } ifelse } for /x1 x
+def /y1 y def /x2 x ml ma cos mul add def /y2 y ml ma sin mul add def
+newpath x1 y1 moveto x2 y2 lineto stroke x2 y2 x1 y1 !psarrow x1 y1
+x2 y2 !psarrow } def /!sign {dup 0 lt {pop -1} {0 eq {0} {1} ifelse}
+ifelse} def /!pslatexline { /L exch def /b exch def /a exch def a 0
+eq {0 L b !sign mul} {L a !sign mul dup b mul a div} ifelse newpath
+0 0 moveto lineto stroke } def /!pslatexvector { /L exch def /b exch
+def /a exch def a 0 eq {0 L b !sign mul} {L a !sign mul dup b mul a
+div} ifelse !psvect } def /!pscircle { 2 div newpath 0 0 3 2 roll 0
+360 arc stroke } def /!psdisk { 2 div newpath 0 0 3 2 roll 0 360 arc
+fill } def
+end \ No newline at end of file
diff --git a/graphics/gastex/gastex.sty b/graphics/gastex/gastex.sty
new file mode 100644
index 0000000000..a9f0a8ad43
--- /dev/null
+++ b/graphics/gastex/gastex.sty
@@ -0,0 +1,1959 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{gastex}[2006/11/28 v2.8]
+\newif\ifgastexslide\gastexslidefalse
+\DeclareOption{slide}{\global\gastexslidetrue}
+\DeclareOption{paper}{\global\gastexslidefalse}
+\ProcessOptions
+\RequirePackage{calc,trig}
+\special{header=gastex.pro}
+% \input gastex.ps
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%
+%% GasTeX : Graphs and Automata Simplified in TeX
+%%
+%% Macros for drawing easily graphs and automata under the picture
+%% environment of LaTeX2e.
+%% See the README file
+%%
+%% Paul Gastin
+%% LSV
+%% ENS de Cachan
+%% 61, avenue du Prˇsident Wilson
+%% F-94235 CACHAN Cedex
+%% FRANCE
+%% http://www.lsv.ens-cachan.fr/~gastin/
+%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% A lot of changes has been made since gastex 1.0 and as a result,
+% these new macros are no longer compatible with the previous ones.
+% To be able to use old pictures, a compatible mode is provided
+% (see \compatiblegastexun at the end of the file). The compatibility
+% is almost 100% and should be sufficient in most cases.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% History since version 2.0
+%
+% 2.8:
+% - packaged for CTAN
+%
+% 2.7:
+% - gastex is now compatible with the xcolor package which allows very
+% useful color expressions such as red!50!blue!60!white.
+%
+% 2.6:
+% - improved precision of some computations
+%
+% 2.5:
+% The horizontal shifts that one gets sometimes (e.g. with overlays in
+% presentations) should no more occur provided \nullfont is used inside the
+% picture environment:
+% \begin{picture}(100,35)(-50,0)\nullfont
+% ...
+% \end{picture}
+% \selectfont is automatically used by gastex for node or edge labels.
+% I found this solution looking in the package pgf (portable graphics
+% format) by Till Tantau. I also recommend his excellent beamer package
+% for laptop presentations.
+%
+% 2.4:
+% - added the macro \rpnode to allow nodes whose shape is a regular polygon
+% defined by its radius, its number of sides and an angle for the first point.
+% - added the possibility to have arrows at the tail of edges and lines.
+% For this, the following new parameters are provided:
+% ATnb, ATdist, ATangle, ATlength, ATLength
+% - added the macro \drawpolygon to draw a polygon defined by a list of points.
+% - added the macro \drawrpolygon to draw a regular polygon defined by
+% its radius, its number of sides and an angle for the first point.
+% - added the macro \drawline to draw a broken line defined by n points.
+% - added the parameter "arcradius" in order to have arcs instead of sharp angles
+% for polygons and broken lines. The default is arcradius=0 for sharp angles.
+% - added the macro \drawcurve to draw a continuous curve going through n points.
+% - added the macro \drawccurve to draw a continuous closed curve going through n points.
+% All these macros use gasset parameters and in particular:
+% Nframe, Nfill, linecolor, fillcolor, dash, ...
+%
+% Uncompatibility: The macro \drawline was introduced in version 2.1 to
+% draw a line between two points. The new version allows to draw a line
+% defined by an arbitrary number of points but the syntax is different.
+% It was \drawline(x1,y1,x2,y2) and it is now \drawline(x1,y1)(x2,y2).
+%
+% 2.3:
+% - added the parameter ELdistC (y or n) allowing to specify whether
+% the distance (ELdist) is between the center (y) of the label and the edge
+% or between the side (n) of the label and the edge.
+% The behaviour of previous gastex versions corresponds to the setting
+% (n) which is therefore the default.
+% - added the macro \drawqbpedge allowing to specify the auxiliary
+% point of a quadratic Bezier curve with two angles instead of the
+% absolute coordinates required by \drawqbedge.
+% - added parameters sxo, syo, exo, eyo (offsets in \unitlength).
+% They define offsets for the virtual starting and ending points of an
+% edge with respect to the centers of the starting and ending nodes.
+% - improved drawing for arrowheads (in gastex.pro).
+% First, the direction of the arrowhead is better for curved edges.
+% Second, when several arrowheads are drawn they follow the curve.
+% Previously, they followed the tangent at the ending point of the
+% edge which was bad for curved edges.
+%
+% 2.2:
+% - added the options slide and paper to the package.
+% In order to get the default settings for slides, use
+% \usepackage[slide]{gastex}
+% The default settings for papers is obtained with
+% \usepackage[paper]{gastex}
+% or
+% \usepackage{gastex}
+% - added new option loopCW to define whether loops are in
+% clockwise direction or not.
+% - Fix a TeX error (Arithmetic overflow) that occurred when using
+% \drawedge(A,B){} with two nodes A and B having the same coordinates.
+% Now, in this case, an error message is issued in the log
+% and the macro \drawedge(A,B){} is ignored.
+%
+% 2.1:
+% - New macros to draw directly circles, rectanges, ovals,
+% lines and bezier curves.
+% \drawcircle, \drawrect, \drawoval,
+% \drawline, \drawqbezier, \drawcbezier
+% All these macros use gasset options and in particular:
+% Nframe, Nfill, linecolor, fillcolor, dash, AHnb, etc...
+% - Compatibility mode for pspictpg up to v0.6
+% - Fix the bug which occured sometimes when using Nw=0,Nh=0.
+%
+% 2.01:
+% - Fix an error that occured in v2.0 when using Nfill=y without
+% defining previously fillgray or fillcolor.
+% The following default setting has been added.
+% \gasset{fillgray=0,Nfill=n} % Not filled but black if filled
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Known problems and (hopefully) solutions.
+%
+% 21/10/99: Frank Goertzen (frank.goertzen@unibw-muenchen.de) has
+% reported that when using gastex together with german an error may
+% occur when running dvips if the german package is loaded first. The
+% solution is to load gastex before german:
+% \usepackage{gastex}
+% \usepackage{german}
+% I have no idea concerning the cause of this error.
+%
+% 07/03/00: A postscript error may occur when using Nw=0,Nh=0.
+% Solution: Use a small value instead of 0, e.g. Nw=0.1,Nh=0.1
+% Fixed in version 2.1.
+%
+% 27/10/00: Using gasset inside a tabular or an array produces an error.
+% The reason is that I'm using the "&" symbol as a marker in order to
+% process gasset options.
+% Solution: Include the whole picture inside an mbox.
+% \begin{tabular}{c}
+% \mbox{\begin{picture}(10,20)(-5,-5)
+% \gasset{ELdist=0}
+% \node(A)(0,0){1}\drawloop(A){$a$}
+% \end{picture}}
+% \end{tabular}
+%
+% pdflatex: gastex does not work with pdflatex since it produces
+% postscript code and pdflatex does not know what to do with it.
+% Solution: Use latex and then ps2pdf.
+% I don't know whether it is possible to translate my postscript code
+% into pdf code. The problem is that I'm using postscript to make some
+% computations and not only to draw the picture.
+% I would appreciate the help of a pdf guru on this.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Internal variables and macros
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\newcounter{cnt@a}\newcounter{cnt@b}\newcounter{cnt@c}
+\newdimen\dim@x \newdimen\dim@y
+\newbox\temp@box
+\newdimen\d@my@unit \d@my@unit=0.01mm
+% \d@my@unit is the unit used for all drawings with gastex.
+% All values given in \unitlength are converted in \d@my@unit.
+% The aim is to improve the precision of the drawings.
+
+{\catcode`t=12\catcode`p=12\gdef\no@PT#1pt{#1}}
+\def\strip@PT#1{\expandafter\no@PT\the#1\space}
+
+\def\gas@initps{!BP
+ \gas@dash
+ \line@width setlinewidth\space}
+
+\def\gas@AHparam{\AH@nb\AH@d\AH@angle\AH@L\AH@l}
+\def\gas@ATparam{\AT@nb\AT@d\AT@angle\AT@L\AT@l}
+\def\gas@ATnul{0 \AT@d\AT@angle\AT@L\AT@l}
+\def\gas@gobble#1{}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Settings
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%-----------------------------------------------------------------------
+% Set values for gastex parameters.
+%
+% \gasset{parameter=value,parameter=value,...}
+% optional spaces are only allowed after commas
+%
+% Nw=number
+% widht in \unitlength of oval nodes
+% Nh=number
+% height in \unitlength of oval nodes
+% Nmr=number
+% maximal radius in \unitlength of oval nodes
+% The actual radius will be min(Nw/2,Nh/2,Nmr)
+% Nmr=0 yields a rectangle node
+%
+% Nadjust=any combination of the letters w,h,n
+% w : the node width is adjusted to the node label width + Nadjustdist
+% h : the node height is adjusted to the node label height + Nadjustdist
+% n : no adjustment
+% Nadjustdist=number
+% distance in \unitlength between the label box and the node frame
+% when using Nadjust
+%
+% Nframe=y or n
+% boolean flag defining whether nodes are framed or not.
+% Nfill=y or n
+% boolean flag defining whether nodes are filled or not.
+% Automatically set to true by the parameters fillgray and fillcolor
+%
+% ExtNL=y or n
+% boolean flag defining whether node labels are external or not.
+% NLangle=number
+% direction in degree of node labels
+% NLdist=number
+% The meaning depends on the ExtNL flag.
+% If the flag is set to "n" then NLdist defines the distance
+% in \unitlength between the node center and the label center.
+% If the flag is set to "y" then NLdist defines the distance
+% in \unitlength between the node frame and the label box.
+%
+% Nmarks=any combination of the letters i,f,r,n
+% i : initial mark on nodes
+% f : final mark on nodes
+% r : repeated mark on nodes
+% n : no mark on nodes
+% ilength=number
+% length in \unitlength of arrows marking initial nodes
+% iangle=number
+% direction in degree of arrows marking initial nodes
+% flength=number
+% length in \unitlength of arrows marking final nodes
+% fangle=number
+% direction in degree of arrows marking final nodes
+% rdist=number
+% distance in \unitlength between the lines of repeated nodes
+% a positive value draw the second line inside the normal one
+% a negative value draw the second line outside the normal one
+% but the edges are still connected to the normal line.
+%
+% An edge virtually starts from the center of the starting node and
+% ends at the center of the ending node (indeed they are only drawn
+% outside of the nodes). It is possible to change the virtual starting
+% and ending points of an edge using offsets with respect to the center
+% of the starting and ending node. This is the purpose of the following
+% parameters.
+% sxo=number (starting x offset)
+% horizontal offset in \unitlength of the starting point of an edge
+% with respect to the center of the starting node.
+% syo=number (starting y offset)
+% vertical offset in \unitlength of the starting point of an edge
+% with respect to the center of the starting node.
+% exo=number (ending x offset)
+% horizontal offset in \unitlength of the ending point of an edge
+% with respect to the center of the ending node.
+% eyo=number (ending y offset)
+% vertical offset in \unitlength of the ending point of an edge
+% with respect to the center of the ending node.
+%
+% curvedepth=number
+% depth in \unitlength of curved edges between two nodes
+% The absolute value of curvedepth defines the distance between the
+% middle of the curved edge and the center of the line joining the two nodes
+% With a positive/negative value the curved edge is on the left/right
+% of the line joining the two nodes.
+%
+% loopdiam=number
+% diameters in \unitlength of loops
+% loopangle=number
+% direction in degree of loops
+% loopCW=y or n
+% boolean flag defining whether loops are in clockwise direction or not.
+%
+% AHnb=number
+% number of arrow(s) at the head of edges.
+% 0 for no arrowhead.
+% AHdist=number
+% distance in \unitlength between two arrowheads
+% AHangle=angle
+% angle in degree between the edge and the arrowhead side
+% AHLength=number
+% Length in \unitlegth of the arrowhead side
+% AHlength=number
+% length in \unitlegth defining the shape of the arrowhead
+% 0 for an arrowhead formed with just two lines
+% Length*cos(angle) for a triangular arrowhead
+% See examples.
+%
+% ATnb=number
+% number of arrow(s) at the tail of edges.
+% 0 for no arrowhead.
+% ATdist=number
+% distance in \unitlength between two arrowtails
+% ATangle=angle
+% angle in degree between the edge and the arrowtail side
+% ATLength=number
+% Length in \unitlegth of the arrowtail side
+% ATlength=number
+% length in \unitlegth defining the shape of the arrowtail
+% 0 for an arrowtail formed with just two lines
+% Length*cos(angle) for a triangular arrowtail
+% See examples.
+%
+% ELside=l or r
+% label on the (l)eft or (r)ight side of the edge
+% ELpos=0..100
+% position of the label along the edge.
+% 0 : starting node
+% 50 : middle of the edge
+% 100 : ending node
+% ELdist=number
+% distance in \unitlength between the label and the edge
+% ELdistC=y or n
+% y : The distance is between the center of the label and the edge.
+% With ELdist=0 the center of the label is on the edge.
+% n : The distance is between the side of the label and the edge.
+% This is the default.
+% The distance is actually between the side of the label and
+% the tangent of the edge which is usually a good approximation.
+% It may not work very well if the label is large and the edge is
+% strongly curved because then the tangent is far from the edge at the
+% point that achieve the distance between the tangent and the label.
+%
+% linegray=decimal number between 0 and 1
+% gray level used to draw lines. 0=black, 1=white.
+% fillgray=decimal number between 0 and 1
+% gray level used to fill nodes. 0=black, 1=white.
+% linecolor=ColorName
+% color used to draw lines.
+% The color name should be defined in dvipsnam.def and one should
+% include \usepackage[usenames]{color}.
+% This is to avoid the trouble of defining our own colors.
+% The drawback is that it is not possible to define and use other colors.
+% It should not be very restrictive since plenty of colours are
+% defined in dvipsnam.def.
+% It should not be difficult to add the possibility of using new
+% colors if needed.
+% fillcolor=ColorName
+% color used to fill nodes. See remarks above.
+% linewidth=number
+% width in \unitlegth of lines
+% dash={list of numbers}{offset}
+% Set the dash pattern used for drawing postscript paths.
+% The numbers in the list indicate alternatively lengths
+% in \unitlength of dashes and lengths in \unitlength of spaces.
+% The list of lenghts is used circularly.
+% offset allows to start the pattern at some distance from its beginning.
+% Here are some examples:
+% dash={}{0} % continuous path
+% dash={1.5}0 % dashs of length 1.5 and empty spaces of length 1.5
+% dash={0.2 0.5}0 % looks like a sequence of dots
+% dash={4 1 1 1}0 % alternation of long and short dashs
+% dash={1.5}{1.5} % we start with the empty space and not the dash
+% dash={4}{2} % we start in the middle of the first dash
+%
+% arcradius=number
+% radius in \unitlength of the arcs used at the vertices
+% of polygons and broken lines. 0 for sharp angles.
+% polyangle=angle
+% angle in degrees with respect to the x axis of the first vertex
+% of the regular polygon.
+%
+\def\gasset#1{\gas@set#1,&}%
+\def\gas@set#1=#2,{\ignorespaces%
+ \@ifundefined{gasset@#1}
+ {\PackageWarning{gastex}{Parameter #1 undefined}{}}
+ {\csname gasset@#1\endcsname{#2}}%
+ \@ifnextchar&{\gas@gobble}{\gas@set}}
+
+\def\gasset@Nw#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\N@w{\thecnt@a}}%
+\def\gasset@Nh#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\N@h{\thecnt@a}}%
+\def\gasset@Nmr#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\N@mr{\thecnt@a}}%
+
+\newif\if@wadjust \newif\if@hadjust \newif\if@nadjust
+\def\gasset@Nadjust#1{%
+ \@wadjustfalse \@hadjustfalse \gasset@@Nadjust #1&}
+\def\gasset@@Nadjust#1{%
+ \@ifundefined{if@#1adjust}
+ {\PackageWarning{gastex}{Node adjust #1 undefined}{}}
+ {\csname @#1adjusttrue\endcsname}%
+ \@ifnextchar&{\gas@gobble}{\gasset@@Nadjust}}
+\def\gasset@Nadjustdist#1{%
+ \setcounter{cnt@a}{2*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\N@adjustdist{\thecnt@a}}%
+
+\newif\if@frame \newif\if@fill \newif\if@ExtNL
+\def\flag@y{\relax}\def\flag@n{\relax}
+\def\gasset@Nframe#1{%
+ \@ifundefined{flag@#1}
+ {\PackageWarning{gastex}{Nframe value should be y or n}{}}
+ {\if#1y \@frametrue \else \@framefalse \fi}}
+\def\gasset@Nfill#1{%
+ \@ifundefined{flag@#1}
+ {\PackageWarning{gastex}{Nfill value should be y or n}{}}
+ {\if#1y \@filltrue \else \@fillfalse \fi}}
+\def\gasset@ExtNL#1{%
+ \@ifundefined{flag@#1}
+ {\PackageWarning{gastex}{ExtNL value should be y or n}{}}
+ {\if#1y \@ExtNLtrue \else \@ExtNLfalse \fi}}
+
+\def\gasset@NLangle#1{\edef\NL@angle{#1}}%
+\def\gasset@NLdist#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\NL@dist{\thecnt@a}}%
+
+\newif\if@imark \newif\if@fmark \newif\if@rmark \newif\if@nmark
+\def\gasset@Nmarks#1{%
+ \@imarkfalse \@fmarkfalse \@rmarkfalse \gasset@@Nmarks #1&}
+\def\gasset@@Nmarks#1{%
+ \@ifundefined{if@#1mark}
+ {\PackageWarning{gastex}{Node mark #1 undefined}{}}
+ {\csname @#1marktrue\endcsname}%
+ \@ifnextchar&{\gas@gobble}{\gasset@@Nmarks}}
+
+\def\gasset@ilength#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\i@length{\thecnt@a}}%
+\def\gasset@iangle#1{\edef\i@angle{#1}}%
+\def\gasset@flength#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\f@length{\thecnt@a}}%
+\def\gasset@fangle#1{\edef\f@angle{#1}}%
+\def\gasset@rdist#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\rep@dist{\thecnt@a}}%
+
+\def\gasset@sxo#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\E@sxo{\thecnt@a}}%
+\def\gasset@syo#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\E@syo{\thecnt@a}}%
+\def\gasset@exo#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\E@exo{\thecnt@a}}%
+\def\gasset@eyo#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\E@eyo{\thecnt@a}}%
+
+\def\gasset@curvedepth#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\curve@depth{\thecnt@a}}%
+
+\def\gasset@loopdiam#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\loop@diam{\thecnt@a}}%
+\def\gasset@loopangle#1{\edef\loop@angle{#1}}%
+\newif\if@loopCW
+\def\gasset@loopCW#1{%
+ \@ifundefined{flag@#1}
+ {\PackageWarning{gastex}{loopCW value should be y or n}{}}
+ {\if#1y \@loopCWtrue \else \@loopCWfalse \fi}}
+
+\def\gasset@AHnb#1{\edef\AH@nb{#1\space}}%
+\def\gasset@AHdist#1{%
+ \dim@x=#1\unitlength \edef\AH@d{\strip@PT\dim@x}}%
+\def\gasset@AHangle#1{\edef\AH@angle{#1\space}}%
+\def\gasset@AHLength#1{%
+ \dim@x=#1\unitlength \edef\AH@L{\strip@PT\dim@x}}%
+\def\gasset@AHlength#1{%
+ \dim@x=#1\unitlength \edef\AH@l{\strip@PT\dim@x}}%
+
+\def\gasset@ATnb#1{\edef\AT@nb{#1\space}}%
+\def\gasset@ATdist#1{%
+ \dim@x=#1\unitlength \edef\AT@d{\strip@PT\dim@x}}%
+\def\gasset@ATangle#1{\edef\AT@angle{#1\space}}%
+\def\gasset@ATLength#1{%
+ \dim@x=#1\unitlength \edef\AT@L{\strip@PT\dim@x}}%
+\def\gasset@ATlength#1{%
+ \dim@x=#1\unitlength \edef\AT@l{\strip@PT\dim@x}}%
+
+\def\ELside@l{\relax}\def\ELside@r{\relax}
+\def\gasset@ELside#1{%
+ \@ifundefined{ELside@#1}
+ {\PackageWarning{gastex}{ELside value should be l or r}{}}
+ {\edef\EL@s{#1}}}%
+\def\gasset@ELpos#1{
+ \ifnum#1>100
+ \PackageWarning{gastex}{ELpos value should be between 0 and 100}{}
+ \else\ifnum#1<0
+ \PackageWarning{gastex}{ELpos value should be between 0 and 100}{}
+ \else\edef\EL@p{#1}\fi\fi}%
+\def\gasset@ELdist#1{%
+ \setcounter{cnt@a}{1*\ratio{#1\unitlength}{\d@my@unit}}
+ \edef\EL@dist{\thecnt@a}}%
+\newif\if@ELdistC
+\def\gasset@ELdistC#1{%
+ \@ifundefined{flag@#1}
+ {\PackageWarning{gastex}{ELdistC value should be y or n}{}}
+ {\if#1y \@ELdistCtrue \else \@ELdistCfalse \fi}}
+
+\def\gas@rgb@model{setrgbcolor}%
+\def\gas@cmyk@model{setcmykcolor}%
+\def\gas@gray@model{setgray}%
+\def\gas@color#1#2{\@ifundefined{gas@#1@model}%
+ {\PackageWarning{gastex}{Color model '#1' not supported}{}}
+ {\def\gas@tmp@col{}\gas@recode #2,&}%
+ \edef\gas@tmp@col{\gas@tmp@col\csname gas@#1@model\endcsname}}%
+\def\gas@recode#1,{\edef\gas@tmp@col{\gas@tmp@col #1 }%
+ \@ifnextchar&{\gas@gobble}{\gas@recode}}
+
+\def\gasset@linegray#1{\edef\line@color{#1 setgray\space}}%
+\def\gasset@linecolor#1{\@ifundefined{extractcolorspec}%
+ {\@ifundefined{\string\color @#1}
+ {\PackageWarning{gastex}{Color #1 undefined}{}}
+ {\edef\line@color{#1\space}}}%
+ {\extractcolorspec{#1}{\gas@tmp@color}%
+ \expandafter\gas@color\gas@tmp@color%
+ \edef\line@color{\gas@tmp@col\space}}}%
+
+\def\gasset@fillgray#1{\@filltrue\edef\fill@color{#1 setgray\space}}%
+\def\gasset@fillcolor#1{\@ifundefined{extractcolorspec}%
+ {\@ifundefined{\string\color @#1}
+ {\PackageWarning{gastex}{Color #1 undefined}{}}
+ {\@filltrue\edef\fill@color{#1\space}}}%
+ {\extractcolorspec{#1}{\gas@tmp@color}%
+ \expandafter\gas@color\gas@tmp@color%
+ \@filltrue\edef\fill@color{\gas@tmp@col\space}}}%
+
+\def\gasset@linewidth#1{%
+ \dim@x=#1\unitlength \edef\line@width{\strip@PT\dim@x}}%
+\def\gasset@dash#1{\gasset@@dash #1}%
+\def\gasset@@dash#1#2{%
+ \def\gas@dash{[}%
+ \gas@convert 0 #1 &
+ \dim@x=#2\unitlength
+ \edef\gas@dash{\gas@dash] \strip@PT\dim@x setdash\space}}%
+\def\gas@convert#1 {%
+ \dim@x=#1\unitlength
+ \ifdim\dim@x=0pt\else\edef\gas@dash{\gas@dash\strip@PT\dim@x}\fi%
+ \@ifnextchar&{\gas@gobble}{\gas@convert}}
+
+\def\gasset@arcradius#1{%
+ \dim@x=#1\unitlength \edef\arc@radius{\strip@PT\dim@x}}%
+\def\gasset@polyangle#1{\edef\poly@angle{#1}}%
+
+%-----------------------------------------------------------------------
+% Default settings
+\unitlength=1mm
+\gasset{Nw=8,Nh=8,Nmr=4} % circle
+\gasset{Nframe=y}
+\gasset{fillgray=0,Nfill=n} % Not filled but black if filled
+\gasset{ExtNL=n,NLangle=90,NLdist=0}
+\gasset{iangle=180,ilength=5}
+\gasset{fangle=0,flength=5}
+\gasset{rdist=0.7}
+\gasset{Nmarks=n} % no mark
+\gasset{Nadjustdist=1,Nadjust=n} % no adjust
+\gasset{sxo=0,syo=0,exo=0,eyo=0}
+\gasset{curvedepth=0}
+\gasset{loopdiam=8,loopangle=90,loopCW=y}
+% One triangular small arrowhead
+\gasset{AHnb=1,AHdist=1.41,AHangle=20,AHLength=1.5,AHlength=1.41}
+\gasset{ATnb=0,ATdist=1.41,ATangle=20,ATLength=1.5,ATlength=1.41}
+\gasset{ELside=l,ELpos=50,ELdist=1}
+\gasset{linegray=0} % black lines
+\gasset{linewidth=0.14,dash={}0} % continuous path
+\gasset{arcradius=0,polyangle=0} % sharp angles
+
+% Settings for slides
+\ifgastexslide
+ \gasset{Nw=12,Nh=12,Nmr=6,ilength=8,flength=8,rdist=1,loopdiam=12}
+ \gasset{linewidth=0.21,AHdist=2.1,AHLength=2.25,AHlength=2.1}
+ \gasset{ATdist=2.1,ATLength=2.25,ATlength=2.1}
+\fi
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Nodes
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%-----------------------------------------------------------------------
+% Define and draw a node whose shape is a regular polygon.
+%
+% \rpnode(NodeName)(x,y)(n,r){NodeLabel}
+% \rpnode[parameter=value,...](NodeName)(x,y)(n,r){NodeLabel}
+%
+% Required arguments:
+% NodeName : name of the node
+% x,y : coordinates in \unitlengh of the node (center of the polygon).
+% n : number of sides of the polygon.
+% r : radius in \unitlengh of the circle containing the polygon.
+% NodeLabel : label of the node. Empty if no label.
+% Optional argument: (in particular, polyangle and arcradius)
+% [parameter=value,...]
+% One may just define a node without drawing it using an empty label
+% and the parameters Nframe=n,Nfill=n
+\def\rpnode#1(#2)(#3)(#4)#5{{%
+ \@ifnextchar[{\process@rpnodeopt}{\rp@node}#1(#2)(#3)(#4){#5}}}
+\def\process@rpnodeopt[#1]{\gas@set#1,&\rp@node}%
+\def\rp@node(#1)(#2,#3)(#4,#5)#6{{%
+% The value -1 assigned to node@#1@w characterizes polygonal nodes
+ \global\expandafter\edef\csname node@#1@w\endcsname{-1}%
+ \setcounter{cnt@a}{1*\ratio{#2\unitlength}{\d@my@unit}}
+ \global\expandafter\edef\csname node@#1@x\endcsname{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#3\unitlength}{\d@my@unit}}
+ \global\expandafter\edef\csname node@#1@y\endcsname{\thecnt@a}%
+ \global\expandafter\edef\csname node@#1@n\endcsname{#4}%
+ \setcounter{cnt@a}{1*\ratio{#5\unitlength}{\d@my@unit}}
+ \global\expandafter\edef\csname node@#1@rad\endcsname{\thecnt@a}%
+ \global\expandafter\edef\csname node@#1@a\endcsname{\poly@angle}%
+% Definition of the polygonal path for the node
+ \dim@x=\csname node@#1@x\endcsname\d@my@unit
+ \dim@y=\csname node@#1@y\endcsname\d@my@unit
+ \edef\ps@path{\strip@PT\dim@x\strip@PT\dim@y\csname node@#1@n\endcsname\space}%
+ \dim@x=\csname node@#1@rad\endcsname\d@my@unit
+ \edef\ps@path{\ps@path \strip@PT\dim@x \csname node@#1@a\endcsname\space}%
+ \edef\ps@path{\ps@path \arc@radius 0 !psrpolygonpath\space}%
+ \global\expandafter\edef\csname node@#1@path\endcsname{\ps@path}%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color \csname node@#1@path\endcsname fill
+ \fi
+ \if@frame
+ \line@color \csname node@#1@path\endcsname stroke
+ \fi
+ }}
+ \if@imark \imark(#1) \fi
+ \if@fmark \fmark(#1) \fi
+ \if@rmark \rmark(#1) \fi
+% \@ExtNLfalse
+ \nodelabel(#1){#6}
+}}
+
+%-----------------------------------------------------------------------
+% Define and draw a node.
+%
+% \node(NodeName)(x,y){NodeLabel}
+% \node[parameter=value,...](NodeName)(x,y){NodeLabel}
+%
+% Required arguments:
+% NodeName : name of the node
+% (x,y) : coordinates of the node in \unitlengh.
+% NodeLabel : label of the node. Empty if no label.
+% Optional argument:
+% [parameter=value,...]
+% One may just define a node without drawing it using an empty label
+% and the parameters Nframe=n,Nfill=n
+\def\node#1(#2)(#3,#4)#5{{%
+ \@ifnextchar[{\process@nodeopt}{\i@node}#1(#2)(#3,#4){#5}}}
+\def\process@nodeopt[#1]{\gas@set#1,&\i@node}%
+\def\i@node(#1)(#2,#3)#4{%
+ \let@node(#1)(#2,#3){#4}\draw@node(#1){#4}}
+
+%-----------------------------------------------------------------------
+% Define a node without drawing it.
+% Internal macro also used in \compatiblegastexun.
+%
+% \let@node(NodeName)(x,y){NodeLabel}
+%
+% Required arguments:
+% NodeName : name of the node
+% x,y : coordinates of the node in \unitlengh.
+% NodeLabel : label of the node. Empty if no label.
+\def\let@node(#1)(#2,#3)#4{{%
+% width and height of the box containing #4
+ \setbox\temp@box\hbox{\selectfont #4}
+ \if@wadjust
+ \setcounter{cnt@a}{\N@adjustdist + \wd\temp@box / \d@my@unit}
+ \edef\N@w{\thecnt@a}%
+ \fi
+ \if@hadjust
+ \setcounter{cnt@a}{\N@adjustdist + (\ht\temp@box+\dp\temp@box) / \d@my@unit}
+ \edef\N@h{\thecnt@a}%
+ \fi
+ \global\expandafter\edef\csname node@#1@w\endcsname{\N@w}%
+ \global\expandafter\edef\csname node@#1@h\endcsname{\N@h}%
+ \ifnum\N@h<\N@w
+ \setcounter{cnt@a}{\N@h/2}
+ \else
+ \setcounter{cnt@a}{\N@w/2}
+ \fi
+ \ifnum\N@mr<\thecnt@a\setcounter{cnt@a}{\N@mr}\fi
+ \global\expandafter\edef\csname node@#1@r\endcsname{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#2\unitlength}{\d@my@unit}}
+ \global\expandafter\edef\csname node@#1@x\endcsname{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#3\unitlength}{\d@my@unit}}
+ \global\expandafter\edef\csname node@#1@y\endcsname{\thecnt@a}%
+% Definition of the oval path for the node
+ \dim@x=#2\unitlength \edef\ps@path{\strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=\N@w\d@my@unit \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=\N@h\d@my@unit \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=\N@mr\d@my@unit \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \edef\ps@path{\ps@path !psovalpath\space}%
+ \global\expandafter\edef\csname node@#1@path\endcsname{\ps@path}%
+}}
+
+%-----------------------------------------------------------------------
+% Draw a node which is already defined. Internal macro.
+%
+% \draw@node(NodeName){NodeLabel}
+%
+% Required arguments:
+% NodeName : name of the node
+% NodeLabel : label of the node. Empty if no label.
+\def\draw@node(#1)#2{{%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color \csname node@#1@path\endcsname fill
+ \fi
+ \if@frame
+ \line@color \csname node@#1@path\endcsname stroke
+ \fi
+ }}
+ \if@imark \imark(#1) \fi
+ \if@fmark \fmark(#1) \fi
+ \if@rmark \rmark(#1) \fi
+ \nodelabel(#1){#2}
+}}
+
+%-----------------------------------------------------------------------
+% Add an ingoing arrow to mark an initial node.
+% This arrow is usually drawn by \node using Nmarks=i.
+% This separate macro can be used to draw several arrows
+% or arrows with different colors, thickness, dash, ...
+%
+% \imark(NodeName)
+% \imark[parameter=value,...](NodeName)
+%
+% Required arguments:
+% NodeName : name of the node
+% Optional argument:
+% [parameter=value,...]
+\def\imark#1(#2){{%
+ \@ifnextchar[{\process@imarkopt}{\i@mark}#1(#2)}}
+\def\process@imarkopt[#1]{\gas@set#1,&\i@mark}%
+\def\i@mark(#1){{%
+ \dim@x=\csname node@#1@x\endcsname\d@my@unit \edef\ps@par{\strip@PT\dim@x}%
+ \dim@x=\csname node@#1@y\endcsname\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x}%
+ \dim@x=\i@length\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x \i@angle\space}%
+ \put(0,0){\special{" \gas@initps \line@color
+% Path around the node
+ \csname node@#1@path\endcsname /path!a false upath cvlit def
+ \gas@ATnul \gas@AHparam \ps@par !node_mark}}
+}}
+
+%-----------------------------------------------------------------------
+% Add an outgoing arrow to mark a final node.
+% This arrow is usually drawn by \node using Nmarks=f.
+% This separate macro can be used to draw several arrows
+% or arrows with different colors, thickness, dash, ...
+%
+% \fmark(NodeName)
+% \fmark[parameter=value,...](NodeName)
+%
+% Required arguments:
+% NodeName : name of the node
+% Optional argument:
+% [parameter=value,...]
+\def\fmark#1(#2){{%
+ \@ifnextchar[{\process@fmarkopt}{\f@mark}#1(#2)}}
+\def\process@fmarkopt[#1]{\gas@set#1,&\f@mark}%
+\def\f@mark(#1){{%
+ \dim@x=\csname node@#1@x\endcsname\d@my@unit \edef\ps@par{\strip@PT\dim@x}%
+ \dim@x=\csname node@#1@y\endcsname\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x}%
+ \dim@x=\f@length\d@my@unit \edef\ps@par{\ps@par \strip@PT\dim@x \f@angle\space}%
+ \put(0,0){\special{" \gas@initps \line@color
+% Path around the node
+ \csname node@#1@path\endcsname /path!a false upath cvlit def
+ \gas@AHparam \gas@ATnul \ps@par !node_mark}}
+}}
+
+%-----------------------------------------------------------------------
+% Add a second line to mark a repeated node.
+% This line is usually drawn by \node using Nmarks=r.
+% This separate macro can be used to draw several lines around the
+% node or lines with different colors, thickness, dash, ...
+%
+% \rmark(NodeName)
+% \rmark[parameter=value,...](NodeName)
+%
+% Required arguments:
+% NodeName : name of the node
+% Optional argument:
+% [parameter=value,...]
+\def\rmark#1(#2){{%
+ \@ifnextchar[{\process@rmarkopt}{\r@mark}#1(#2)}}
+\def\process@rmarkopt[#1]{\gas@set#1,&\r@mark}%
+\def\r@mark(#1){{%
+ \ifnum\csname node@#1@w\endcsname=-1 % then it's a polygonal node
+ \dim@x=\csname node@#1@x\endcsname\d@my@unit
+ \edef\ps@path{\strip@PT\dim@x}%
+ \dim@x=\csname node@#1@y\endcsname\d@my@unit
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \edef\ps@path{\ps@path \csname node@#1@n\endcsname\space}%
+ \dim@x=\csname node@#1@rad\endcsname\d@my@unit
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \edef\ps@path{\ps@path \csname node@#1@a\endcsname\space}%
+ \dim@y=\rep@dist\d@my@unit
+ \edef\ps@path{\ps@path \arc@radius \strip@PT\dim@y !psrpolygonpath\space}%
+ \put(0,0){\special{" \gas@initps \line@color \ps@path stroke}}
+ \else % it's an oval node
+ \dim@x=\csname node@#1@x\endcsname\d@my@unit
+ \edef\ps@path{\strip@PT\dim@x}%
+ \dim@x=\csname node@#1@y\endcsname\d@my@unit
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@y=-\rep@dist\d@my@unit
+ \dim@x=\csname node@#1@w\endcsname\d@my@unit
+ \advance\dim@x\dim@y\advance\dim@x\dim@y
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=\csname node@#1@h\endcsname\d@my@unit
+ \advance\dim@x\dim@y\advance\dim@x\dim@y
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=\csname node@#1@r\endcsname\d@my@unit
+ \advance\dim@x\dim@y
+ \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps \line@color \ps@path !psovalpath stroke}}
+ \fi
+}}
+
+%-----------------------------------------------------------------------
+% Add a label to the node.
+% The position of the label is determined by the ExtNL flag
+% and the parameters NLangle and NLdist.
+% The label is usually drawn by \node.
+% This separate macro can be used to add several labels
+%
+% \nodelabel(NodeName){NodeLabel}
+% \nodelabel[parameter=value,...](NodeName){NodeLabel}
+%
+% Required arguments:
+% NodeName : name of the node
+% NodeLabel : label of the node.
+% Optional argument:
+% [parameter=value,...]
+\newif\if@cosneg \newif\if@sinneg
+\def\nodelabel#1(#2)#3{{%
+ \@ifnextchar[{\process@nodelabelopt}{\node@label}#1(#2){#3}}}
+\def\process@nodelabelopt[#1]{\gas@set#1,&\node@label}%
+\def\node@label(#1)#2{{%
+ \unitlength=\d@my@unit
+ \edef\cs@x{\csname node@#1@x\endcsname}%
+ \edef\cs@y{\csname node@#1@y\endcsname}%
+ \if@ExtNL
+ \node@diam(#1,\NL@angle)
+ \setcounter{cnt@a}{\cs@nd/2}\edef\cs@nr{\thecnt@a}%
+% width and height of the box containing #2
+ \setbox\temp@box\hbox{\selectfont #2}
+ \setcounter{cnt@a}{\wd\temp@box / \d@my@unit}
+ \edef\cs@bw{\thecnt@a}%
+ \setcounter{cnt@a}{(\ht\temp@box+\dp\temp@box) / \d@my@unit}
+ \edef\cs@bh{\thecnt@a}%
+%
+ \@cosnegfalse \@sinnegfalse
+ \dim@x=\cs@cos pt \ifnum \dim@x<0 \@cosnegtrue \dim@x=-\dim@x \fi
+ \edef\cs@abscos{\strip@PT\dim@x}%
+ \dim@x=\cs@sin pt \ifnum \dim@x<0 \@sinnegtrue \dim@x=-\dim@x \fi
+ \edef\cs@abssin{\strip@PT\dim@x}%
+%
+ \ifnum\csname node@#1@w\endcsname=-1 % then it's a polygonal node
+ \setcounter{cnt@c}{\cs@nr+\NL@dist+%
+ (\cs@bw*\real{\cs@abscos}+\cs@bh*\real{\cs@abssin})/2}
+ \setcounter{cnt@a}{\cs@x+\thecnt@c*\real{\cs@cos}}
+ \setcounter{cnt@b}{\cs@y+\thecnt@c*\real{\cs@sin}}
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #2}}
+ \else % it's an oval node
+ \setcounter{cnt@a}{((\cs@h+\cs@bh)/2+\NL@dist)*\real{\cs@abscos}}
+ \setcounter{cnt@b}{((\cs@w+\cs@bw)/2-\cs@r)*\real{\cs@abssin}}
+ \ifnum\thecnt@a<\thecnt@b
+ \setcounter{cnt@c}{(\cs@h+\cs@bh)/2+\NL@dist}
+ \if@sinneg \setcounter{cnt@c}{-\thecnt@c} \fi
+ \setcounter{cnt@a}{\cs@x+\thecnt@c*\real{\cs@cos}/\real{\cs@sin}}
+ \setcounter{cnt@b}{\cs@y+\thecnt@c}
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #2}}
+ \else
+ \setcounter{cnt@a}{((\cs@w+\cs@bw)/2+\NL@dist)*\real{\cs@abssin}}
+ \setcounter{cnt@b}{((\cs@h+\cs@bh)/2-\cs@r)*\real{\cs@abscos}}
+ \ifnum\thecnt@a<\thecnt@b
+ \setcounter{cnt@c}{(\cs@w+\cs@bw)/2+\NL@dist}
+ \if@cosneg \setcounter{cnt@c}{-\thecnt@c} \fi
+ \setcounter{cnt@a}{\cs@x+\thecnt@c}
+ \setcounter{cnt@b}{\cs@y+\thecnt@c*\real{\cs@sin}/\real{\cs@cos}}
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #2}}
+ \else
+ % auxiliary parameters
+ \setcounter{cnt@a}{\cs@r-(\cs@w+\cs@bw)/2}
+ \edef\cs@xx{\thecnt@a}%
+ \setcounter{cnt@a}{\cs@r-(\cs@h+\cs@bh)/2}
+ \edef\cs@yy{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@r+\NL@dist)*(\cs@r+\NL@dist)}
+ \edef\cs@lim{\thecnt@a}%
+ \def\cs@tmin{0}%
+ \setcounter{cnt@a}{\NL@dist+(\cs@bw+\cs@bh)/2}
+ \edef\cs@tmax{\thecnt@a}%
+ % computation of the center of the label
+ \setcounter{cnt@c}{10}
+ \@whilenum\thecnt@c>0\do{
+ \setcounter{cnt@a}{(\cs@tmin+\cs@tmax)/2}
+ \edef\cs@t{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@nr+\cs@t)*\real{\cs@abscos}+\cs@xx}
+ \setcounter{cnt@b}{(\cs@nr+\cs@t)*\real{\cs@abssin}+\cs@yy}
+ \setcounter{cnt@a}{\thecnt@a*\thecnt@a + \thecnt@b*\thecnt@b}
+ \ifnum\thecnt@a<\cs@lim
+ \edef\cs@tmin{\cs@t}%
+ \else
+ \edef\cs@tmax{\cs@t}%
+ \fi
+ \addtocounter{cnt@c}{-1}}
+ \setcounter{cnt@a}{\cs@x+(\cs@nr+\cs@t)*\real{\cs@cos}}
+ \setcounter{cnt@b}{\cs@y+(\cs@nr+\cs@t)*\real{\cs@sin}}
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #2}}
+ \fi
+ \fi
+ \fi
+ \else % regular node label
+ \CalculateCos{\NL@angle} \edef\cs@cos{\UseCos{\NL@angle}}%
+ \CalculateSin{\NL@angle} \edef\cs@sin{\UseSin{\NL@angle}}%
+ \setcounter{cnt@a}{\cs@x+\NL@dist*\real{\cs@cos}}
+ \setcounter{cnt@b}{\cs@y+\NL@dist*\real{\cs@sin}}
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #2}}
+ \fi
+}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Edges
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%-----------------------------------------------------------------------
+% Edge between two nodes.
+%
+% \drawedge(startingNode,endingNode){label}
+% \drawedge[parameter=value,...](startingNode,endingNode){label}
+%
+% Required arguments:
+% startingNode : name of the starting node,
+% endingNode : name of the ending node,
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawedge#1(#2)#3{{%
+ \@ifnextchar[{\process@edgeopt}{\draw@edge}#1(#2){#3}}}
+\def\process@edgeopt[#1]{\gas@set#1,&\draw@edge}%
+\def\draw@edge(#1,#2)#3{%
+% Control points of the cubic Bezier curve
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#2@x\endcsname + \E@exo}%
+ \edef\cs@xd{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#2@y\endcsname + \E@eyo}%
+ \edef\cs@yd{\thecnt@a}%
+ \setcounter{cnt@a}{\cs@xd-\cs@xa}
+ \setcounter{cnt@b}{\cs@yd-\cs@ya}
+ \setcounter{cnt@c}{\thecnt@a*\thecnt@a+\thecnt@b*\thecnt@b}
+ \ifnum\thecnt@c=0
+ \PackageError{gastex}{drawedge(#1,#2)}{}
+ \typeout{The starting and ending nodes should not have the same coordinates.}
+ \else
+ \gas@sqrt{\thecnt@c}
+ \setcounter{cnt@b}{\cs@xa+\cs@xd-4*\curve@depth*(\cs@yd-\cs@ya)/\the@sqrt}
+ \setcounter{cnt@a}{(\thecnt@b+\cs@xa)/3}\edef\cs@xb{\thecnt@a}%
+ \setcounter{cnt@a}{(\thecnt@b+\cs@xd)/3}\edef\cs@xc{\thecnt@a}%
+ \setcounter{cnt@b}{\cs@ya+\cs@yd+4*\curve@depth*(\cs@xd-\cs@xa)/\the@sqrt}
+ \setcounter{cnt@a}{(\thecnt@b+\cs@ya)/3}\edef\cs@yb{\thecnt@a}%
+ \setcounter{cnt@a}{(\thecnt@b+\cs@yd)/3}\edef\cs@yc{\thecnt@a}%
+ \unitlength=\d@my@unit
+ \draw@b@edge(#1,#2){#3}
+ \fi
+}
+
+%-----------------------------------------------------------------------
+% Edge between two nodes following a quadratic Bezier curve.
+% The first and last control points are the centers of the starting
+% and ending nodes resp, modified with the starting and ending offsets.
+% The middle control point is given by its absolute cartesian coordinates
+%
+% \drawqbedge(startingNode,x,y,endingNode){label}
+% \drawqbedge[parameter=value,...](startingNode,x,y,endingNode){label}
+%
+% Required arguments:
+% startingNode : name of the starting node,
+% x,y : coordinates in \unitlength of the intermediary control point
+% endingNode : name of the ending node,
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawqbedge#1(#2)#3{{%
+ \@ifnextchar[{\process@qbedgeopt}{\draw@qbedge}#1(#2){#3}}}
+\def\process@qbedgeopt[#1]{\gas@set#1,&\draw@qbedge}%
+\def\draw@qbedge(#1,#2,#3,#4)#5{%
+% Control points of the cubic Bezier curve
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@x\endcsname + \E@exo}%
+ \edef\cs@xd{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@y\endcsname + \E@eyo}%
+ \edef\cs@yd{\thecnt@a}%
+ \setcounter{cnt@b}{2*\ratio{#2\unitlength}{\d@my@unit}}
+ \setcounter{cnt@a}{(\cs@xa+\thecnt@b)/3}\edef\cs@xb{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@xd+\thecnt@b)/3}\edef\cs@xc{\thecnt@a}%
+ \setcounter{cnt@b}{2*\ratio{#3\unitlength}{\d@my@unit}}
+ \setcounter{cnt@a}{(\cs@ya+\thecnt@b)/3}\edef\cs@yb{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@yd+\thecnt@b)/3}\edef\cs@yc{\thecnt@a}%
+ \unitlength=\d@my@unit
+ \draw@b@edge(#1,#4){#5}
+}
+
+%-----------------------------------------------------------------------
+% Edge between two nodes following a quadratic Bezier curve.
+% The first and last control points are the centers of the starting
+% and ending nodes resp, modified with the starting and ending offsets.
+% The middle control point is defined by two angles.
+%
+% \drawqbpedge(startingNode,sa,endingNode,ea){label}
+% \drawqbpedge[parameter=value,...](startingNode,sa,endingNode,ea){label}
+%
+% Required arguments:
+% startingNode : name of the starting node,
+% endingNode : name of the ending node,
+% sa,ea : angles in degree at the starting and ending nodes,
+% these angles define intermediary control point
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawqbpedge#1(#2)#3{{%
+ \@ifnextchar[{\process@qbpedgeopt}{\draw@qbpedge}#1(#2){#3}}}
+\def\process@qbpedgeopt[#1]{\gas@set#1,&\draw@qbpedge}%
+\def\draw@qbpedge(#1,#2,#3,#4)#5{%
+% Control points of the cubic Bezier curve
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#3@x\endcsname + \E@exo}%
+ \edef\cs@xd{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#3@y\endcsname + \E@eyo}%
+ \edef\cs@yd{\thecnt@a}%
+ \edef\cs@sangle{#2}%
+ \CalculateCos\cs@sangle \CalculateSin\cs@sangle
+ \edef\cs@eangle{#4}%
+ \CalculateCos\cs@eangle \CalculateSin\cs@eangle
+ \setcounter{cnt@a}{1000*\real{\UseCos\cs@sangle}*\real{\UseSin\cs@eangle}
+ -1000*\real{\UseSin\cs@sangle}*\real{\UseCos\cs@eangle}}
+ \ifnum\thecnt@a=0
+ \PackageError{gastex}{drawqbpedge(#1,#2,#3,#4)}{}
+ \typeout{The angles do not allow to compute the intersection point.}
+ \else
+ \setcounter{cnt@c}{((\cs@xd-\cs@xa)*1000*\real{\UseSin\cs@eangle}
+ -(\cs@yd-\cs@ya)*1000*\real{\UseCos\cs@eangle})
+ /\thecnt@a}
+ \setcounter{cnt@b}{2*(\cs@xa+\thecnt@c*\real{\UseCos\cs@sangle})}
+ \setcounter{cnt@a}{(\cs@xa+\thecnt@b)/3}\edef\cs@xb{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@xd+\thecnt@b)/3}\edef\cs@xc{\thecnt@a}%
+ \setcounter{cnt@b}{2*(\cs@ya+\thecnt@c*\real{\UseSin\cs@sangle})}
+ \setcounter{cnt@a}{(\cs@ya+\thecnt@b)/3}\edef\cs@yb{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@yd+\thecnt@b)/3}\edef\cs@yc{\thecnt@a}%
+ \unitlength=\d@my@unit
+ \draw@b@edge(#1,#3){#5}
+ \fi
+}
+
+%-----------------------------------------------------------------------
+% Edge between two nodes following a cubic Bezier curve.
+% The first and last control points are the centers of the starting
+% and ending nodes resp, modified with the starting and ending offsets.
+% The second and third control points are given by their polar coordinates
+% relative to the first and last control points resp.
+%
+% \drawbpedge(startingNode,sa,sr,endingNode,ea,er){label}
+% \drawbpedge[parameter=value,...](startingNode,sa,sr,endingNode,ea,er){label}
+%
+% Required arguments:
+% startingNode : name of the starting node,
+% sa,sr : polar coordinates of the second control point relative to the
+% first control point (angle in degree and radius in \unitlength)
+% endingNode : name of the ending node,
+% ea,er : polar coordinates of the third control point relative to the
+% last control point (angle in degree and radius in \unitlength)
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawbpedge#1(#2)#3{{%
+ \@ifnextchar[{\process@bpedgeopt}{\draw@bpedge}#1(#2){#3}}}
+\def\process@bpedgeopt[#1]{\gas@set#1,&\draw@bpedge}%
+\def\draw@bpedge(#1,#2,#3,#4,#5,#6)#7{%
+% Control points of the cubic Bezier curve
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@x\endcsname + \E@exo}%
+ \edef\cs@xd{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@y\endcsname + \E@eyo}%
+ \edef\cs@yd{\thecnt@a}%
+ \setcounter{cnt@b}{1*\ratio{#3\unitlength}{\d@my@unit}}
+ \edef\cs@angle{#2}%
+ \CalculateCos\cs@angle \CalculateSin\cs@angle
+ \setcounter{cnt@a}{\cs@xa+\thecnt@b*\real{\UseCos\cs@angle}}
+ \edef\cs@xb{\thecnt@a}%
+ \setcounter{cnt@a}{\cs@ya+\thecnt@b*\real{\UseSin\cs@angle}}
+ \edef\cs@yb{\thecnt@a}%
+ \setcounter{cnt@b}{1*\ratio{#6\unitlength}{\d@my@unit}}
+ \edef\cs@angle{#5}%
+ \CalculateCos\cs@angle \CalculateSin\cs@angle
+ \setcounter{cnt@a}{\cs@xd+\thecnt@b*\real{\UseCos\cs@angle}}
+ \edef\cs@xc{\thecnt@a}%
+ \setcounter{cnt@a}{\cs@yd+\thecnt@b*\real{\UseSin\cs@angle}}
+ \edef\cs@yc{\thecnt@a}%
+ \unitlength=\d@my@unit
+ \draw@b@edge(#1,#4){#7}
+}
+
+%-----------------------------------------------------------------------
+% Edge between two nodes following a cubic Bezier curve.
+% The first and last control points are the centers of the starting
+% and ending nodes resp, modified with the starting and ending offsets.
+% The second and third control points are given by their absolute
+% cartesian coordinates.
+%
+% \drawbcedge(startingNode,xs,ys,endingNode,xe,ye){label}
+% \drawbcedge[parameter=value,...](startingNode,xs,ys,endingNode,xe,ye){label}
+%
+% Required arguments:
+% startingNode : name of the starting node,
+% xs,ys : coordinates in \unitlength of the control point defining
+% the tangent at the starting node
+% endingNode : name of the ending node,
+% xe,ye : coordinates in \unitlength of the control point defining
+% the tangent at the ending node
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawbcedge#1(#2)#3{{%
+ \@ifnextchar[{\process@bcedgeopt}{\draw@bcedge}#1(#2){#3}}}
+\def\process@bcedgeopt[#1]{\gas@set#1,&\draw@bcedge}%
+\def\draw@bcedge(#1,#2,#3,#4,#5,#6)#7{%
+% Control points of the cubic Bezier curve
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@x\endcsname + \E@exo}%
+ \edef\cs@xd{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#4@y\endcsname + \E@eyo}%
+ \edef\cs@yd{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#2\unitlength}{\d@my@unit}}
+ \edef\cs@xb{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#3\unitlength}{\d@my@unit}}
+ \edef\cs@yb{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#5\unitlength}{\d@my@unit}}
+ \edef\cs@xc{\thecnt@a}%
+ \setcounter{cnt@a}{1*\ratio{#6\unitlength}{\d@my@unit}}
+ \edef\cs@yc{\thecnt@a}%
+ \unitlength=\d@my@unit
+ \draw@b@edge(#1,#4){#7}
+}
+
+%-----------------------------------------------------------------------
+% Loop on a node following a cubic Bezier curve.
+% Only the starting offsets sxo and syo are used.
+%
+% \drawloop(Node){label}
+% \drawloop[parameter=value,...](Node){label}
+%
+% Required arguments:
+% Node : name of the node,
+% label : label of the edge. {} for no label.
+% Optional argument:
+% [parameter=value,...]
+\def\drawloop#1(#2)#3{{%
+ \@ifnextchar[{\process@loopopt}{\draw@loop}#1(#2){#3}}}
+\def\process@loopopt[#1]{\gas@set#1,&\draw@loop}%
+\def\draw@loop(#1)#2{%
+% Control points of the cubic Bezier curve
+ \unitlength=\d@my@unit
+ \setcounter{cnt@a}{\csname node@#1@x\endcsname + \E@sxo}%
+ \edef\cs@xa{\thecnt@a}%
+ \setcounter{cnt@a}{\csname node@#1@y\endcsname + \E@syo}%
+ \edef\cs@ya{\thecnt@a}%
+ \edef\cs@xd{\cs@xa}%
+ \edef\cs@yd{\cs@ya}%
+ \node@diam(#1,\loop@angle)
+ \setcounter{cnt@a}{2*(\cs@nd+2*\loop@diam)/3}
+ \setcounter{cnt@b}{\loop@diam*1732/1000} % approx of sqrt(3)
+% Rotation
+ \setcounter{cnt@c}
+ {\cs@xa+\thecnt@a*\real{\cs@cos}-\thecnt@b*\real{\cs@sin}}
+ \if@loopCW
+ \edef\cs@xb{\thecnt@c}%
+ \else
+ \edef\cs@xc{\thecnt@c}%
+ \fi
+ \setcounter{cnt@c}
+ {\cs@xa+\thecnt@a*\real{\cs@cos}+\thecnt@b*\real{\cs@sin}}
+ \if@loopCW
+ \edef\cs@xc{\thecnt@c}%
+ \else
+ \edef\cs@xb{\thecnt@c}%
+ \fi
+ \setcounter{cnt@c}
+ {\cs@ya+\thecnt@a*\real{\cs@sin}+\thecnt@b*\real{\cs@cos}}
+ \if@loopCW
+ \edef\cs@yb{\thecnt@c}%
+ \else
+ \edef\cs@yc{\thecnt@c}%
+ \fi
+ \setcounter{cnt@c}
+ {\cs@ya+\thecnt@a*\real{\cs@sin}-\thecnt@b*\real{\cs@cos}}
+ \if@loopCW
+ \edef\cs@yc{\thecnt@c}%
+ \else
+ \edef\cs@yb{\thecnt@c}%
+ \fi
+ \draw@b@edge(#1,#1){#2}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Other macros
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%-----------------------------------------------------------------------
+% Draw a broken line defined by n points (n>1).
+% The line may have arrowhead(s), arrowtail(s), color, ...
+% depending of the current settings
+%
+% \drawline(x1,y1)...(xn,yn)
+% \drawline[parameter=value,...](x1,y1)...(xn,yn)
+%
+% Required arguments in \unitlengh:
+% (x1,y1)...(xn,yn) : coordinates of the points.
+% Optional argument:
+% [parameter=value,...]
+\def\drawline#1(#2){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \@ifnextchar[{\process@drawlineopt}{\draw@line}#1(#2)}
+\def\process@drawlineopt[#1]{\gas@set#1,&\draw@line}%
+\def\draw@line(#1,#2){%
+ \setcounter{cnt@a}{\thecnt@a+1}
+ \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \@ifnextchar({\draw@line}{
+ \put(0,0){\special{" \gas@initps \line@color
+ \gas@ATparam \gas@AHparam \ps@param \thecnt@a\space \arc@radius !pslines}}
+ \endgroup
+ }}
+
+%-----------------------------------------------------------------------
+% Draw a circle.
+%
+% \drawcircle(x,y,r)
+% \drawcircle[parameter=value,...](x,y,d)
+%
+% Required arguments in \unitlengh:
+% x,y : coordinates of the circle center.
+% d : diameter of the circle.
+% Optional argument:
+% [parameter=value,...]
+\def\drawcircle#1(#2){{%
+ \@ifnextchar[{\process@circleopt}{\draw@circle}#1(#2)}}
+\def\process@circleopt[#1]{\gas@set#1,&\draw@circle}%
+\def\draw@circle(#1,#2,#3){{%
+ \dim@x=#1\unitlength \edef\ps@x{\strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@y{\strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@d{\strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color
+ \ps@x \ps@y \ps@d 2 div !pscirclepath fill
+ \fi
+ \if@frame
+ \line@color
+ \ps@x \ps@y \ps@d 2 div !pscirclepath stroke
+ \fi
+ }}
+}}
+
+%-----------------------------------------------------------------------
+% Draw a rectangle.
+%
+% \drawrect(x0,y0,x1,y1)
+% \drawrect[parameter=value,...](x0,y0,x1,y1)
+%
+% Required arguments in \unitlengh:
+% x0,y0 : coordinates of the lower left corner of the rectangle.
+% x1,y1 : coordinates of the upper right corner of the rectangle.
+% Optional argument:
+% [parameter=value,...]
+\def\drawrect#1(#2){{%
+ \@ifnextchar[{\process@rectopt}{\draw@rect}#1(#2)}}
+\def\process@rectopt[#1]{\gas@set#1,&\draw@rect}%
+\def\draw@rect(#1,#2,#3,#4){{%
+ \dim@x=#1\unitlength \edef\ps@x{\strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@y{\strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@a{\strip@PT\dim@x}%
+ \dim@x=#4\unitlength \edef\ps@b{\strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color
+ \ps@x \ps@y \ps@a \ps@b !psrectpath fill
+ \fi
+ \if@frame
+ \line@color
+ \ps@x \ps@y \ps@a \ps@b !psrectpath stroke
+ \fi
+ }}
+}}
+
+%-----------------------------------------------------------------------
+% Draw an oval.
+%
+% \drawoval(x,y,w,h,mr)
+% \drawoval[parameter=value,...](x,y,w,h,mr)
+%
+% Required arguments in \unitlengh:
+% x,y : coordinates of the oval center.
+% w,h : width and height of the oval.
+% rm : defines the maximal radius for the corners.
+% Optional argument:
+% [parameter=value,...]
+\def\drawoval#1(#2){{%
+ \@ifnextchar[{\process@ovalopt}{\draw@oval}#1(#2)}}
+\def\process@ovalopt[#1]{\gas@set#1,&\draw@oval}%
+\def\draw@oval(#1,#2,#3,#4,#5){{%
+ \dim@x=#1\unitlength \edef\ps@path{\strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=#4\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \dim@x=#5\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \edef\ps@path{\ps@path !psovalpath\space}%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color \ps@path fill
+ \fi
+ \if@frame
+ \line@color \ps@path stroke
+ \fi
+ }}
+}}
+
+%-----------------------------------------------------------------------
+% Draw a polygon defined by n points (n>1).
+% The polygon may be framed and/or filled depending on the current parameters.
+%
+% \drawpolygon(x1,y1)...(xn,yn)
+% \drawpolygon[parameter=value,...](x1,y1)...(xn,yn)
+%
+% Required arguments in \unitlengh:
+% (x1,y1)...(xn,yn) : coordinates of the points.
+% Optional argument:
+% [parameter=value,...]
+\def\drawpolygon#1(#2){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \@ifnextchar[{\process@polygonopt}{\draw@polygon}#1(#2)}
+\def\process@polygonopt[#1]{\gas@set#1,&\draw@polygon}%
+\def\draw@polygon(#1,#2){%
+ \setcounter{cnt@a}{\thecnt@a+1}
+ \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \@ifnextchar({\draw@polygon}{
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color
+ \ps@param \thecnt@a\space \arc@radius !pspolygonpath fill
+ \fi
+ \if@frame
+ \line@color
+ \ps@param \thecnt@a\space \arc@radius !pspolygonpath stroke
+ \fi
+ }}
+ \endgroup
+ }}
+
+%-----------------------------------------------------------------------
+% Draw a regular polygon
+% The polygon may be framed and/or filled depending on the current parameters.
+%
+% \drawrpolygon(x,y)(n,r)
+% \drawrpolygon[parameter=value,...](x,y)(n,r)
+%
+% Required arguments:
+% x,y : coordinates in \unitlengh of the center of the polygon.
+% n : number of sides of the polygon.
+% r : radius in \unitlengh of the polygon.
+% Optional argument: (in particular, polyangle and arcradius)
+% [parameter=value,...]
+\def\drawrpolygon#1(#2)(#3){\begingroup%
+ \@ifnextchar[{\process@rpolygonopt}{\draw@rpolygon}#1(#2)(#3)}
+\def\process@rpolygonopt[#1]{\gas@set#1,&\draw@rpolygon}%
+\def\draw@rpolygon(#1,#2)(#3,#4){%
+ \dim@x=#1\unitlength \dim@y=#2\unitlength
+ \edef\ps@path{\strip@PT\dim@x \strip@PT\dim@y #3\space}%
+ \dim@x=#4\unitlength \edef\ps@path{\ps@path \strip@PT\dim@x}%
+ \edef\ps@path{\ps@path \poly@angle\space \arc@radius 0 !psrpolygonpath\space}%
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color \ps@path fill
+ \fi
+ \if@frame
+ \line@color \ps@path stroke
+ \fi
+ }}
+ \endgroup}
+
+%-----------------------------------------------------------------------
+% Draw closed curve defined by n points (n>1).
+% Between each pair of consecutive points, we use a cubic Bezier curve.
+% The control points of the cubic Bezier curves are determined so that
+% the whole curve is C^1 and the tangent at each point is orthogonal to
+% the bisector at this point.
+% The closed curve may be framed and/or filled depending on
+% the current parameters.
+%
+% \drawccurve(x1,y1)...(xn,yn)
+% \drawccurve[parameter=value,...](x1,y1)...(xn,yn)
+%
+% Required arguments in \unitlengh:
+% (x1,y1)...(xn,yn) : coordinates of the points.
+% Optional argument:
+% [parameter=value,...]
+\def\drawccurve#1(#2){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \@ifnextchar[{\process@drawccurveopt}{\draw@c@curve}#1(#2)}
+\def\process@drawccurveopt[#1]{\gas@set#1,&\draw@c@curve}%
+\def\draw@c@curve(#1,#2){%
+ \setcounter{cnt@a}{\thecnt@a+1}
+ \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \@ifnextchar({\draw@c@curve}{
+ \put(0,0){\special{" \gas@initps
+ \if@fill
+ \fill@color
+ \ps@param \thecnt@a\space !psccurvepath fill
+ \fi
+ \if@frame
+ \line@color
+ \ps@param \thecnt@a\space !psccurvepath stroke
+ \fi
+ }}
+ \endgroup
+}}
+
+%-----------------------------------------------------------------------
+% Draw curve defined by n points (n>1).
+% Between each pair of consecutive points, we use a cubic Bezier curve.
+% The control points of the cubic Bezier curves are determined so that
+% the whole curve is C^1 and the tangent at each point is orthogonal to
+% the bisector at this point.
+%
+% \drawcurve(x1,y1)...(xn,yn)
+% \drawcurve[parameter=value,...](x1,y1)...(xn,yn)
+%
+% Required arguments in \unitlengh:
+% (x1,y1)...(xn,yn) : coordinates of the points.
+% Optional argument:
+% [parameter=value,...]
+\def\drawcurve#1(#2){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \@ifnextchar[{\process@drawcurveopt}{\draw@curve}#1(#2)}
+\def\process@drawcurveopt[#1]{\gas@set#1,&\draw@curve}%
+\def\draw@curve(#1,#2){%
+ \setcounter{cnt@a}{\thecnt@a+1}
+ \dim@x=#1\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@param{\ps@param \strip@PT\dim@x}%
+ \@ifnextchar({\draw@curve}{
+ \put(0,0){\special{" \gas@initps \line@color
+ \gas@ATparam \gas@AHparam
+ \ps@param \thecnt@a\space !pscurve}}
+ \endgroup
+}}
+
+%-----------------------------------------------------------------------
+% Draw a quadratic Bezier curve.
+% The line may have arrowhead(s), ... depending of the current settings
+%
+% \drawqbezier(x0,y0,x1,y1,x2,y2)
+% \drawqbezier[parameter=value,...](x0,y0,x1,y1,x2,y2)
+%
+% \drawqbezier arguments:
+% x0,y0,x1,y1,x2,y2 : coordinates in \unitlength of the control points
+% Optional argument:
+% [parameter=value,...]
+\def\drawqbezier#1(#2){{%
+ \@ifnextchar[{\process@drawqbezieropt}{\draw@q@bezier}#1(#2)}}
+\def\process@drawqbezieropt[#1]{\gas@set#1,&\draw@q@bezier}%
+\def\draw@q@bezier(#1,#2,#3,#4,#5,#6){{%
+ \dim@x=#1\unitlength \edef\ps@xa{\strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@ya{\strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@xb{\strip@PT\dim@x}%
+ \dim@x=#4\unitlength \edef\ps@yb{\strip@PT\dim@x}%
+ \dim@x=#5\unitlength \edef\ps@xc{\strip@PT\dim@x}%
+ \dim@x=#6\unitlength \edef\ps@yc{\strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps \line@color
+ \gas@ATparam \gas@AHparam
+ \ps@xa \ps@ya \ps@xb \ps@yb \ps@xc \ps@yc !ps_qbezier}}
+}}
+
+%-----------------------------------------------------------------------
+% Draw a cubic Bezier curve.
+% The line may have arrowhead(s), ... depending of the current settings
+%
+% \drawcbezier(x0,y0,x1,y1,x2,y2,x3,y3)
+% \drawcbezier[parameter=value,...](x0,y0,x1,y1,x2,y2,x3,y3)
+%
+% \drawcbezier arguments:
+% x0,y0,x1,y1,x2,y2,x3,y3 : coordinates in \unitlength of the control points
+% Optional argument:
+% [parameter=value,...]
+\def\drawcbezier#1(#2){{%
+ \@ifnextchar[{\process@drawcbezieropt}{\draw@c@bezier}#1(#2)}}
+\def\process@drawcbezieropt[#1]{\gas@set#1,&\draw@c@bezier}%
+\def\draw@c@bezier(#1,#2,#3,#4,#5,#6,#7,#8){{%
+ \dim@x=#1\unitlength \edef\ps@xa{\strip@PT\dim@x}%
+ \dim@x=#2\unitlength \edef\ps@ya{\strip@PT\dim@x}%
+ \dim@x=#3\unitlength \edef\ps@xb{\strip@PT\dim@x}%
+ \dim@x=#4\unitlength \edef\ps@yb{\strip@PT\dim@x}%
+ \dim@x=#5\unitlength \edef\ps@xc{\strip@PT\dim@x}%
+ \dim@x=#6\unitlength \edef\ps@yc{\strip@PT\dim@x}%
+ \dim@x=#7\unitlength \edef\ps@xd{\strip@PT\dim@x}%
+ \dim@x=#8\unitlength \edef\ps@yd{\strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps \line@color
+ \gas@ATparam \gas@AHparam
+ \ps@xa \ps@ya \ps@xb \ps@yb \ps@xc \ps@yc \ps@xd \ps@yd !ps_cbezier}}
+}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Internal macros
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%-----------------------------------------------------------------------
+% Compute the diameter of a node in some direction
+%
+% \node@diam(Node,angle)
+%
+% Result in \cs@nd.
+% Byproduct: \cs@cos=cos(angle), \cs@sin=sin(angle) are also defined.
+%
+% There are 3 cases depending on whether the direction intersects the node
+% on a vertical line, an horizontal line or a rounded corner.
+\def\node@diam(#1,#2){%
+ \CalculateCos{#2} \edef\cs@cos{\UseCos{#2}}%
+ \CalculateSin{#2} \edef\cs@sin{\UseSin{#2}}%
+ \ifnum\csname node@#1@w\endcsname=-1 % then it's a polygonal node
+ \edef\cs@rad{\csname node@#1@rad\endcsname}%
+ \edef\cs@n{\csname node@#1@n\endcsname}%
+ \edef\cs@a{\csname node@#1@a\endcsname}%
+ \setcounter{cnt@b}{360/\cs@n}\edef\cs@b{\thecnt@b}%
+ \setcounter{cnt@a}{#2-\cs@a}
+ \@whilenum\thecnt@a>\thecnt@b\do{\setcounter{cnt@a}{\thecnt@a-\thecnt@b}}
+ \@whilenum\thecnt@a<0\do{\setcounter{cnt@a}{\thecnt@a+\thecnt@b}}
+ \setcounter{cnt@b}{\thecnt@b/2}
+ \setcounter{cnt@a}{\thecnt@a-\thecnt@b}
+ \ifnum\thecnt@a<0 \setcounter{cnt@a}{-\thecnt@a} \fi
+ \CalculateCos{\thecnt@a} \CalculateCos{\thecnt@b}%
+ \setcounter{cnt@c}{2*\cs@rad*\real{\UseCos{\thecnt@b}}/\real{\UseCos{\thecnt@a}}}
+ \edef\cs@nd{\thecnt@c}%
+ \else % it's an oval node
+ \edef\cs@w{\csname node@#1@w\endcsname}%
+ \edef\cs@h{\csname node@#1@h\endcsname}%
+ \edef\cs@r{\csname node@#1@r\endcsname}%
+ \setcounter{cnt@a}{\cs@r+\cs@r}\edef\cs@rr{\thecnt@a}%
+ \setcounter{cnt@a}{(\cs@h-\cs@rr)*\real{\cs@cos}}
+ \ifnum\thecnt@a<0\edef\cs@A{-\thecnt@a}\else\edef\cs@A{\thecnt@a}\fi%
+ \setcounter{cnt@a}{(\cs@w-\cs@rr)*\real{\cs@sin}}
+ \ifnum\thecnt@a<0\edef\cs@B{-\thecnt@a}\else\edef\cs@B{\thecnt@a}\fi%
+ \setcounter{cnt@a}{\cs@w*\real{\cs@sin}}
+ \ifnum\thecnt@a<0\setcounter{cnt@a}{-\thecnt@a}\fi
+ \ifnum\thecnt@a<\cs@A
+ \setcounter{cnt@c}{\cs@w/\real{\cs@cos}}
+ \ifnum\thecnt@c<0\edef\cs@nd{-\thecnt@c}\else\edef\cs@nd{\thecnt@c}\fi%
+ \else
+ \setcounter{cnt@a}{\cs@h*\real{\cs@cos}}
+ \ifnum\thecnt@a<0\setcounter{cnt@a}{-\thecnt@a}\fi
+ \ifnum\thecnt@a<\cs@B
+ \setcounter{cnt@c}{\cs@h/\real{\cs@sin}}
+ \ifnum\thecnt@c<0\edef\cs@nd{-\thecnt@c}\else\edef\cs@nd{\thecnt@c}\fi%
+ \else
+ \setcounter{cnt@a}{\cs@rr*\cs@rr-(\cs@B-\cs@A)*(\cs@B-\cs@A)}
+ \gas@sqrt{\thecnt@a}
+ \setcounter{cnt@a}{(\cs@w-\cs@rr)*\real{\cs@cos}}
+ \ifnum\thecnt@a<0\edef\cs@E{-\thecnt@a}\else\edef\cs@E{\thecnt@a}\fi%
+ \setcounter{cnt@a}{(\cs@h-\cs@rr)*\real{\cs@sin}}
+ \ifnum\thecnt@a<0\edef\cs@F{-\thecnt@a}\else\edef\cs@F{\thecnt@a}\fi%
+ \setcounter{cnt@a}{\the@sqrt+\cs@E+\cs@F}\edef\cs@nd{\thecnt@a}%
+ \fi
+ \fi
+ \fi
+% \typeout{w=\cs@w,h=\cs@h,r=\cs@r,angle=#2,\cs@nd}
+}
+
+%-----------------------------------------------------------------------
+% Draw the cubic Bezier curve.
+% The control points
+% (\cs@xa,\cs@ya)(\cs@xb,\cs@yb)(\cs@xc,\cs@yc)(\cs@xd,\cs@yd)
+% should already be defined.
+%
+% #1 : name of the starting node
+% #2 : name of the ending node
+% #3 : label of the edge
+\def\draw@b@edge(#1,#2)#3{{%
+% Parameters for the Bezier curve.
+ \dim@x=\cs@xa\unitlength \edef\ps@xa{\strip@PT\dim@x}%
+ \dim@x=\cs@ya\unitlength \edef\ps@ya{\strip@PT\dim@x}%
+ \dim@x=\cs@xb\unitlength \edef\ps@xb{\strip@PT\dim@x}%
+ \dim@x=\cs@yb\unitlength \edef\ps@yb{\strip@PT\dim@x}%
+ \dim@x=\cs@xc\unitlength \edef\ps@xc{\strip@PT\dim@x}%
+ \dim@x=\cs@yc\unitlength \edef\ps@yc{\strip@PT\dim@x}%
+ \dim@x=\cs@xd\unitlength \edef\ps@xd{\strip@PT\dim@x}%
+ \dim@x=\cs@yd\unitlength \edef\ps@yd{\strip@PT\dim@x}%
+ \put(0,0){\special{" \gas@initps \line@color
+% Path around starting node
+ \csname node@#1@path\endcsname /path!a false upath cvlit def
+% Path around ending node
+ \csname node@#2@path\endcsname /path!b false upath cvlit def
+% The curve
+ \gas@ATparam \gas@AHparam
+ \ps@xa \ps@ya \ps@xb \ps@yb \ps@xc \ps@yc \ps@xd \ps@yd !ps_r_cbezier
+ }}
+% Coordinates (\cs@x,\cs@y) and slope (\cs@deltax,\cs@deltay) at the
+% point of the curve defined by the parameter label@pos.
+ \def\@N{100}%
+% coefficients of the polynomial x(t)
+ \setcounter{cnt@a}{\cs@xd-\cs@xa+3*(\cs@xb-\cs@xc)}\edef\@A{\thecnt@a}%
+ \setcounter{cnt@a}{3*(\cs@xa+\cs@xc-2*\cs@xb)}\edef\@B{\thecnt@a}%
+ \setcounter{cnt@a}{3*(\cs@xb-\cs@xa)}\edef\@C{\thecnt@a}%
+% computation of \cs@x and \cs@deltax
+ \setcounter{cnt@a}{((\@A*\EL@p/\@N+\@B)*\EL@p/\@N+\@C)*\EL@p/\@N+\cs@xa}
+ \edef\cs@x{\thecnt@a}%
+ \setcounter{cnt@a}{(3*\@A*\EL@p/\@N+2*\@B)*\EL@p/\@N+\@C}
+ \edef\cs@deltax{\thecnt@a}%
+% coefficients of the polynomial y(t)
+ \setcounter{cnt@a}{\cs@yd-\cs@ya+3*(\cs@yb-\cs@yc)}\edef\@A{\thecnt@a}%
+ \setcounter{cnt@a}{3*(\cs@ya+\cs@yc-2*\cs@yb)}\edef\@B{\thecnt@a}%
+ \setcounter{cnt@a}{3*(\cs@yb-\cs@ya)}\edef\@C{\thecnt@a}%
+% computation of \cs@y and \cs@deltay
+ \setcounter{cnt@a}{((\@A*\EL@p/\@N+\@B)*\EL@p/\@N+\@C)*\EL@p/\@N+\cs@ya}
+ \edef\cs@y{\thecnt@a}%
+ \setcounter{cnt@a}{(3*\@A*\EL@p/\@N+2*\@B)*\EL@p/\@N+\@C}
+ \edef\cs@deltay{\thecnt@a}%
+% Computation of sqrt(\cs@deltax^2+\cs@deltay^2).
+ \setcounter{cnt@c}{\cs@deltax*\cs@deltax+\cs@deltay*\cs@deltay}
+ \gas@sqrt{\thecnt@c}
+ \ifnum\the@sqrt=0\def\the@sqrt{1}\fi
+% Label of the edge.
+% Computation of the shift from C to the center of the label.
+ \if@ELdistC
+ \setcounter{cnt@c}{\EL@dist}
+ \else
+ \setbox\temp@box\hbox{\selectfont #3}
+ \setcounter{cnt@a}{\wd\temp@box / \d@my@unit * \cs@deltay}
+ \ifnum\thecnt@a<0 \setcounter{cnt@a}{-\thecnt@a} \fi
+ \setcounter{cnt@c}{(\ht\temp@box+\dp\temp@box) / \d@my@unit * \cs@deltax}
+ \ifnum\thecnt@c<0 \setcounter{cnt@c}{-\thecnt@c} \fi
+ \setcounter{cnt@c}{(\thecnt@c+\thecnt@a) / \the@sqrt / 2 + \EL@dist}
+ \fi
+ \if r\EL@s
+ \setcounter{cnt@a}{\cs@x + \cs@deltay * \thecnt@c / \the@sqrt}
+ \setcounter{cnt@b}{\cs@y - \cs@deltax * \thecnt@c / \the@sqrt}
+ \else
+ \setcounter{cnt@a}{\cs@x - \cs@deltay * \thecnt@c / \the@sqrt}
+ \setcounter{cnt@b}{\cs@y + \cs@deltax * \thecnt@c / \the@sqrt}
+ \fi
+% Shifting point C and drawing the label.
+ \put(\thecnt@a,\thecnt@b){\makebox(0,0){\selectfont #3}}
+}}
+
+%-----------------------------------------------------------------------
+% Compute the lower interger part of the square root of
+% (the absolute value of) its argument.
+% The result is obtained with \the@sqrt.
+% We use Heron's method which converges quickly.
+\newcounter{cnt@@a}\newcounter{cnt@@b}\newcounter{cnt@@c}
+\def\gas@sqrt#1{%
+ \ifnum#1<0\setcounter{cnt@@a}{-#1}\else\setcounter{cnt@@a}{#1}\fi
+ \ifnum\thecnt@@a>1
+ \setcounter{cnt@@b}{\thecnt@@a}
+ \setcounter{cnt@@c}{(\thecnt@@a+1)/2}
+ \@whilenum\thecnt@@b>\thecnt@@c\do{
+ \setcounter{cnt@@b}{\thecnt@@c}
+ \setcounter{cnt@@c}{(\thecnt@@b+\thecnt@@a/\thecnt@@b)/2}}
+ \edef\the@sqrt{\thecnt@@b}
+ \else
+ \edef\the@sqrt{\thecnt@@a}
+ \fi
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Compatibility with gastex v1.0
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Should be called inside the scope of a group
+%
+% {\compatiblegastexun ... }
+%
+% The macros \drawloop and \drawedge are redefined to match the old
+% ones (v1.0) hence the new ones (v2.0) cannot be used inside the scope
+% of \compatiblegastexun.
+%
+% The compatibility is almost 100%:
+% - the following are ignored
+% \setmaxbezier
+% The optional argument of letstate defining the repeated state diameter
+% - \settransdecal, \setedgedecal give curved edges
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\compatiblegastexun{
+%-----------------------------------------------------------------------
+% Definitions
+%-----------------------------------------------------------------------
+ \unitlength=4pt
+ \d@my@unit= 2048sp % =1/32 pt ~= 0.011 mm
+ \gasset{AHnb=1,AHangle=20}
+ \def\AH@L{\strip@PT\@wholewidth 9 mul }
+ \def\AH@l{\strip@PT\@wholewidth 9 mul 20 cos mul }
+ \def\line@width{\strip@PT\@wholewidth}
+%
+ \def\setstatediam##1{\gasset@Nw{##1}\gasset@Nh{##1}\gasset@Nmr{##1}}
+ \def\setvertexdiam{\setstatediam}
+ \setstatediam{6}
+%
+ \def\setrepeatedstatediam##1{%
+ \setcounter{cnt@a}{1*\ratio{##1\unitlength}{\d@my@unit}}
+ \edef\repeated@diam{\thecnt@a}}%
+ \setrepeatedstatediam{5}
+%
+ \def\setloopdiam{\gasset@loopdiam}%
+ \setloopdiam{6}
+%
+ \def\settranslabelskip{\gasset@ELdist}%
+ \def\setedgelabelskip{\gasset@ELdist}
+ \settranslabelskip{1}
+%
+ \def\setprofcurve##1{%
+ \setcounter{cnt@a}{1*\ratio{##1\unitlength}{\d@my@unit}}
+ \edef\prof@curve{\thecnt@a}}%
+ \setprofcurve{3}
+%
+ \def\settransdecal##1{%
+ \setcounter{cnt@a}{1*\ratio{##1\unitlength}{\d@my@unit}}
+ \edef\trans@decal{\thecnt@a}}%
+ \settransdecal{0}
+ \def\setedgedecal{\settransdecal}
+%
+ \def\setmaxbezier##1{}
+ \def\setnbptbezier##1{} % compatibilite version 0.3
+ \def\setprecision##1{} % compatibilite version 0.3
+%
+ \def\setpsdash{\@ifnextchar[{\i@setpsdash}{\i@setpsdash[0]}}
+ \def\i@setpsdash[##1](##2){%
+ \dim@y=\unitlength \unitlength=1pt
+ \gasset@@dash{0 ##2}{##1}
+ \unitlength=\dim@y
+ \def\ps@dash{[##2] ##1\space}}%
+ \setpsdash() % continuous path
+%
+ \def\pcolor{}
+ \def\pictcolor##1##2{}
+%
+ \def\setpsgray##1{\gasset@linegray{##1}\gasset@fillgray{##1}}%
+ \setpsgray{0} % black
+%-----------------------------------------------------------------------
+% States
+%-----------------------------------------------------------------------
+ \def\letstate{\@ifnextchar[{\i@letstate}{\ii@letstate}}%
+ \def\i@letstate[##1,##2] ##3=(##4,##5){{%
+ \gasset{Nw=##1,Nh=##1,Nmr=##1}
+ \let@node(##3)(##4,##5){}}}
+ \def\ii@letstate ##1=(##2,##3){%
+ \let@node(##1)(##2,##3){}}
+ \def\letvertex{\@ifnextchar[{\i@letvertex}{\ii@letstate}}%
+ \def\i@letvertex[##1] ##2=(##3,##4){{%
+ \gasset{Nw=##1,Nh=##1,Nmr=##1}
+ \let@node(##2)(##3,##4){}}}
+%
+ \def\drawstate(##1)##2{{\gasset{Nfill=n}\draw@node(##1){##2}}}%
+ \def\drawvertex(##1)##2{{\gasset{Nfill=n,Nframe=n}\draw@node(##1){##2}}}%
+ \def\drawcircledvertex{\drawstate}%
+%
+ \def\drawinitialstate{%
+ \@ifnextchar[{\@idrawinitialstate}{\@idrawinitialstate[l]}}
+ \def\@idrawinitialstate[##1](##2)##3{{%
+ \gasset{Nfill=n}\draw@node(##2){##3}
+ \setcounter{cnt@a}{\N@w*\ratio{\d@my@unit}{\unitlength}/2}
+ \if##1l \imark[iangle=180,ilength=\thecnt@a](##2) \fi
+ \if##1r \imark[iangle= 0,ilength=\thecnt@a](##2) \fi
+ \if##1t \imark[iangle= 90,ilength=\thecnt@a](##2) \fi
+ \if##1b \imark[iangle=-90,ilength=\thecnt@a](##2) \fi}}
+%
+ \def\drawfinalstate{%
+ \@ifnextchar[{\@idrawfinalstate}{\@idrawfinalstate[r]}}
+ \def\@idrawfinalstate[##1](##2)##3{{%
+ \gasset{Nfill=n}\draw@node(##2){##3}
+ \setcounter{cnt@a}{\N@w*\ratio{\d@my@unit}{\unitlength}/2}
+ \if##1l \fmark[fangle=180,flength=\thecnt@a](##2) \fi
+ \if##1r \fmark[fangle= 0,flength=\thecnt@a](##2) \fi
+ \if##1t \fmark[fangle= 90,flength=\thecnt@a](##2) \fi
+ \if##1b \fmark[fangle=-90,flength=\thecnt@a](##2) \fi}}
+%
+ \def\drawrepeatedstate(##1)##2{{%
+ \gasset{Nfill=n}\draw@node(##1){##2}
+ \setcounter{cnt@a}{(\N@w-\repeated@diam)/2}
+ \edef\rep@dist{\thecnt@a}%
+ \rmark(##1)}}
+%-----------------------------------------------------------------------
+% Transitions
+%-----------------------------------------------------------------------
+ \let\gas@edge=\drawedge
+ \def\drawtrans{\@ifnextchar[{\@idrawtrans}{\@idrawtrans[l]}}
+ \def\@idrawtrans[##1](##2,##3)##4{%
+ \setcounter{cnt@a}{\trans@decal*\ratio{\d@my@unit}{\unitlength}}
+ \if##1r \gas@edge[ELside=r,curvedepth=\thecnt@a](##2,##3){##4}
+ \else \if##1b \gas@edge[ELside=r,curvedepth=\thecnt@a](##2,##3){##4}
+ \else \gas@edge[ELside=l,curvedepth=\thecnt@a](##2,##3){##4} \fi\fi}
+ \def\drawedge{\drawtrans}
+ \def\drawundirectededge##1(##2,##3)##4{%
+ {\def\AH@nb{0 }\drawtrans##1(##2,##3){##4}}}
+%
+ \def\drawcurvedtrans{%
+ \@ifnextchar[{\@idrawcurvedtrans}{\@idrawcurvedtrans[l]}}
+ \def\@idrawcurvedtrans[##1](##2,##3)##4{%
+ \setcounter{cnt@a}{\prof@curve*\ratio{\d@my@unit}{\unitlength}}
+ \if##1r \gas@edge[ELside=r,curvedepth=\thecnt@a](##2,##3){##4}
+ \else \if##1b \gas@edge[ELside=r,curvedepth=\thecnt@a](##2,##3){##4}
+ \else \gas@edge[ELside=l,curvedepth=\thecnt@a](##2,##3){##4} \fi\fi}
+ \def\drawcurvededge{\drawcurvedtrans}
+ \def\drawundirectedcurvededge##1(##2,##3)##4{%
+ {\def\AH@nb{0 }\drawcurvedtrans##1(##2,##3){##4}}}
+%
+ \def\drawqbeziertrans{%
+ \@ifnextchar[{\@idrawqbeziertrans}{\@idrawqbeziertrans[l]}}
+ \def\@idrawqbeziertrans[##1](##2)(##3,##4)(##5)##6{%
+ \if##1r \drawqbedge[ELside=r](##2,##3,##4,##5){##6}
+ \else \if##1b \drawqbedge[ELside=r](##2,##3,##4,##5){##6}
+ \else \drawqbedge[ELside=l](##2,##3,##4,##5){##6} \fi\fi}
+ \def\drawqbezieredge{\drawqbeziertrans}
+ \def\drawundirectedqbezieredge##1(##2)(##3,##4)(##5)##6{%
+ {\def\AH@nb{0 }\drawqbeziertrans##1(##2)(##3,##4)(##5){##6}}}
+%
+ \def\drawcbeziertrans{%
+ \@ifnextchar[{\@idrawcbeziertrans}{\@idrawcbeziertrans[l]}}
+ \def\@idrawcbeziertrans[##1](##2)(##3,##4)(##5,##6)(##7)##8{{%
+ \if##1r \edef\EL@s{r}
+ \else \if##1b \edef\EL@s{r}
+ \else \edef\EL@s{l} \fi\fi
+ \draw@bcedge(##2,##3,##4,##7,##5,##6){##8}
+ }}
+ \def\drawcbezieredge{\drawcbeziertrans}
+ \def\drawundirectedcbezieredge##1(##2)(##3,##4)(##5,##6)(##7)##8{%
+ {\def\AH@nb{0 }\drawcbeziertrans##1(##2)(##3,##4)(##5,##6)(##7){##8}}}
+%
+ \let\gas@loop=\drawloop
+ \def\drawloop{\@ifnextchar[{\@idrawloop}{\@idrawloop[t]}}%
+ \def\@idrawloop[##1](##2)##3{%
+ \if##1l \gas@loop[loopangle=180](##2){##3} \fi
+ \if##1r \gas@loop[loopangle= 0](##2){##3} \fi
+ \if##1t \gas@loop[loopangle= 90](##2){##3} \fi
+ \if##1b \gas@loop[loopangle=-90](##2){##3} \fi}
+ \def\drawundirectedloop##1(##2)##3{%
+ {\def\AH@nb{0 }\drawloop##1(##2){##3}}}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Compatibility with pspictpg v0.6
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Should be called inside the scope of a group
+%
+% {\compatiblepspictpg ... }
+%
+% The macros \drawline and \drawcircle are redefined to match those of
+% pspictpg hence thoses of GasTeX cannot be used inside the scope
+% of \compatiblepspictpg.
+%
+% The following macros are ignored. Use linecolor and fillcolor instead.
+% \pcolor, \pictcolor
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\compatiblepspictpg{
+%
+ \def\setpsdash{\@ifnextchar[{\i@setpsdash}{\i@setpsdash[0]}}
+ \def\i@setpsdash[##1](##2){%
+ \dim@y=\unitlength \unitlength=1pt
+ \gasset@@dash{0 ##2}{##1}
+ \unitlength=\dim@y
+ \def\ps@dash{[##2] ##1\space}}%
+ \setpsdash() % continuous path
+%
+ \def\pcolor{}
+ \def\pictcolor##1##2{}
+%
+ \def\setpsgray##1{\gasset@linegray{##1}\gasset@fillgray{##1}}%
+ \setpsgray{0} % black
+%
+ % Redefinition of latex \line(a,b){L}.
+ % Can be used with any values for a and b.
+ \def\line(##1,##2)##3{{%
+ \@xarg ##1\relax \@yarg ##2\relax
+ \dim@x=##3\unitlength
+ \special{" \gas@initps \line@color
+ \the\@xarg\space \the\@yarg\space \strip@PT\dim@x !pslatexline}
+ }}
+%
+ % Redefinition of latex \vector(a,b){L}.
+ % Can be used with any values for a and b.
+ \def\vector(##1,##2)##3{{%
+ \@xarg ##1\relax \@yarg ##2\relax
+ \dim@x=##3\unitlength
+ \special{" \gas@initps \line@color \gas@ATnul \gas@AHparam
+ \the\@xarg\space \the\@yarg\space \strip@PT\dim@x !pslatexvector}
+ }}
+%
+ % redefinition of \circle of LaTeX
+ % can be used with any diameter
+ \def\circle{\@ifnextchar*{\@idisk}{\@icircle}}
+ \def\@icircle##1{{%
+ \dim@x=##1\unitlength
+ \special{" \gas@initps \line@color
+ \strip@PT\dim@x !pscircle}
+ }}
+ \def\@idisk*##1{{%
+ \dim@x=##1\unitlength
+ \special{" \gas@initps \fill@color
+ \strip@PT\dim@x !psdisk}
+ }}
+%
+ \def\drawline(##1,##2)(##3,##4){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \process@drawlineopt[ATnb=0,AHnb=0](##1,##2)(##3,##4)}
+ \def\drawvector(##1,##2)(##3,##4){\begingroup%
+ \setcounter{cnt@a}{0} \edef\ps@param{}%
+ \process@drawlineopt[ATnb=0,AHnb=1](##1,##2)(##3,##4)}
+ \def\drawcircle(##1,##2)(##3){{%
+ \gasset{Nframe=y,Nfill=n}\draw@circle(##1,##2,##3)}}
+ \def\drawdisk(##1,##2)(##3){{%
+ \gasset{Nframe=n,Nfill=y}\draw@circle(##1,##2,##3)}}
+ \def\cbezier(##1,##2)(##3,##4)(##5,##6)(##7,##8){%
+ \drawcbezier[ATnb=0,AHnb=0](##1,##2,##3,##4,##5,##6,##7,##8)}
+ \def\cbeziervector(##1,##2)(##3,##4)(##5,##6)(##7,##8){%
+ \drawcbezier[ATnb=0,AHnb=1](##1,##2,##3,##4,##5,##6,##7,##8)}
+ \def\qbezier(##1,##2)(##3,##4)(##5,##6){%
+ \drawqbezier[ATnb=0,AHnb=0](##1,##2,##3,##4,##5,##6)}
+ \def\qbeziervector(##1,##2)(##3,##4)(##5,##6){%
+ \drawqbezier[ATnb=0,AHnb=1](##1,##2,##3,##4,##5,##6)}
+}
+
+\endinput