Source PostScript (arrowhead.pps)

Retour Texte non formaté
/lisere_arrow false def %% 18-06-06 %% %% syntaxe : A B C D (-) gere_arrowhead %% 18-06-06 %% /gere_arrowhead { %% 18-06-06 %% 7 dict begin %% 18-06-06 %% /option exch def %% 18-06-06 %% /D defpoint %% 18-06-06 %% /C defpoint %% 18-06-06 %% /B defpoint %% 18-06-06 %% /A defpoint %% 18-06-06 %% /i option length 1 sub def %% 18-06-06 %% option length 1 gt %% 18-06-06 %% { %% 18-06-06 %% %% on separe l'option pour l'extremite gauche de l'option %% 18-06-06 %% %% pour l'extremite droite %% 18-06-06 %% option 0 get %% 18-06-06 %% dup 45 eq %% c'est le '-' %% 18-06-06 %% exch 61 eq %% c'est le '=' %% 18-06-06 %% or %% 18-06-06 %% { %% 18-06-06 %% /option_gauche () def %% 18-06-06 %% } %% 18-06-06 %% { %% 18-06-06 %% /option_gauche 1 string def %% 18-06-06 %% option_gauche 0 option 0 get put %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% %% 18-06-06 %% option i get %% 18-06-06 %% 45 eq %% c'est le '-' %% 18-06-06 %% { %% 18-06-06 %% /option_droite () def %% 18-06-06 %% } %% 18-06-06 %% { %% 18-06-06 %% /option_droite 1 string def %% 18-06-06 %% option_droite 0 %% 18-06-06 %% option i get %% 18-06-06 %% dup 60 eq %% 18-06-06 %% {pop 62} %% 18-06-06 %% { %% 18-06-06 %% dup 62 eq %% 18-06-06 %% {pop 60} %% 18-06-06 %% { %% 18-06-06 %% dup 40 eq %% 18-06-06 %% {pop 41} %% 18-06-06 %% { %% 18-06-06 %% dup 41 eq %% 18-06-06 %% {pop 40} %% 18-06-06 %% { %% 18-06-06 %% dup 91 eq %% 18-06-06 %% {pop 93} %% 18-06-06 %% { %% 18-06-06 %% dup 93 eq %% 18-06-06 %% {pop 91} %% 18-06-06 %% if %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% put %% 18-06-06 %% } %% 18-06-06 %% ifelse %% 18-06-06 %% A B option_gauche arrowhead %% 18-06-06 %% C D option_droite arrowhead %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% %% 18-06-06 %% end %% 18-06-06 %% } def %% 18-06-06 %% %% 18-06-06 %% %% le dessin se fait en A, le segment venant de B %% 18-06-06 %% %% syntaxe : B A (option) arrowhead %% 18-06-06 %% /arrowhead { %% 18-06-06 %% 3 dict begin %% 18-06-06 %% /option exch def %% 18-06-06 %% /A defpoint %% 18-06-06 %% /B defpoint %% 18-06-06 %% option () eq %% 18-06-06 %% {} %% 18-06-06 %% if %% 18-06-06 %% option (<) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle 180 add rotate %% 18-06-06 %% .5 .5 scale %% 18-06-06 %% lisere_arrow { %% 18-06-06 %% %% on fait un masquage (la couleur du fond est supposee %% 18-06-06 %% %% blanche), de facon a effacer les fins de traits sous %% 18-06-06 %% %% les fleches %% 18-06-06 %% gsave %% 18-06-06 %% currentlinewidth arrowlength arrowscale pop mul mul %% 18-06-06 %% arrowsize arrowscale exch pop mul div 2 mul %% 18-06-06 %% 0 translate %% 18-06-06 %% 1 1 1 setrgbcolor %% 18-06-06 %% arrow %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% arrow %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (>) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle rotate %% 18-06-06 %% .5 .5 scale %% 18-06-06 %% arrow %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (\() eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle rotate %% 18-06-06 %% O exclu %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (\)) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle 180 add rotate %% 18-06-06 %% O exclu %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (]) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle rotate %% 18-06-06 %% cr@chet %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option ([) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A stranslate %% 18-06-06 %% A B pangle 180 add rotate %% 18-06-06 %% cr@chet %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (o) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A circ %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% option (*) eq %% 18-06-06 %% { %% 18-06-06 %% gsave %% 18-06-06 %% A dot %% 18-06-06 %% grestore %% 18-06-06 %% } %% 18-06-06 %% if %% 18-06-06 %% end %% 18-06-06 %% } def %% 23_06-06 %% %% syntaxe : A A' B C C' D (-) gere_arrowhead %% 23_06-06 %% /gere_arrowhead { %% 23_06-06 %% 7 dict begin %% 23_06-06 %% /option exch def %% 23_06-06 %% /D defpoint %% 23_06-06 %% /C' defpoint %% 23_06-06 %% /C defpoint %% 23_06-06 %% /B defpoint %% 23_06-06 %% /A' defpoint %% 23_06-06 %% /A defpoint %% 23_06-06 %% /i option length 1 sub def %% 23_06-06 %% option length 1 gt %% 23_06-06 %% { %% 23_06-06 %% %% on separe l'option pour l'extremite gauche de l'option %% 23_06-06 %% %% pour l'extremite droite %% 23_06-06 %% option 0 get %% 23_06-06 %% dup 45 eq %% c'est le '-' %% 23_06-06 %% exch 61 eq %% c'est le '=' %% 23_06-06 %% or %% 23_06-06 %% { %% 23_06-06 %% /option_gauche () def %% 23_06-06 %% } %% 23_06-06 %% { %% 23_06-06 %% /option_gauche 1 string def %% 23_06-06 %% option_gauche 0 option 0 get put %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% %% 23_06-06 %% option i get %% 23_06-06 %% 45 eq %% c'est le '-' %% 23_06-06 %% { %% 23_06-06 %% /option_droite () def %% 23_06-06 %% } %% 23_06-06 %% { %% 23_06-06 %% /option_droite 1 string def %% 23_06-06 %% option_droite 0 %% 23_06-06 %% option i get %% 23_06-06 %% dup 60 eq %% 23_06-06 %% {pop 62} %% 23_06-06 %% { %% 23_06-06 %% dup 62 eq %% 23_06-06 %% {pop 60} %% 23_06-06 %% { %% 23_06-06 %% dup 40 eq %% 23_06-06 %% {pop 41} %% 23_06-06 %% { %% 23_06-06 %% dup 41 eq %% 23_06-06 %% {pop 40} %% 23_06-06 %% { %% 23_06-06 %% dup 91 eq %% 23_06-06 %% {pop 93} %% 23_06-06 %% { %% 23_06-06 %% dup 93 eq %% 23_06-06 %% {pop 91} %% 23_06-06 %% if %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% put %% 23_06-06 %% } %% 23_06-06 %% ifelse %% 23_06-06 %% A A' B option_gauche arrowhead %% 23_06-06 %% C C' D option_droite arrowhead %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% %% 23_06-06 %% end %% 23_06-06 %% } def %% 23_06-06 %% %% 23_06-06 %% %% le dessin se fait en A, le segment venant de B %% 23_06-06 %% %% syntaxe : B A' A (option) arrowhead %% 23_06-06 %% /arrowhead { %% 23_06-06 %% 3 dict begin %% 23_06-06 %% /option exch def %% 23_06-06 %% /A defpoint %% 23_06-06 %% /A' defpoint %% 23_06-06 %% /B defpoint %% 23_06-06 %% option () eq %% 23_06-06 %% {} %% 23_06-06 %% if %% 23_06-06 %% option (<) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% %% A stranslate %% 23_06-06 %% %% A B pangle 180 add rotate %% 23_06-06 %% %% .5 .5 scale %% 23_06-06 %% %% lisere_arrow { %% 23_06-06 %% %% %% on fait un masquage (la couleur du fond est supposee %% 23_06-06 %% %% %% blanche), de facon a effacer les fins de traits sous %% 23_06-06 %% %% %% les fleches %% 23_06-06 %% %% gsave %% 23_06-06 %% %% currentlinewidth arrowlength arrowscale pop mul mul %% 23_06-06 %% %% arrowsize arrowscale exch pop mul div 2 mul %% 23_06-06 %% %% 0 translate %% 23_06-06 %% %% 1 1 1 setrgbcolor %% 23_06-06 %% %% arrow %% 23_06-06 %% %% grestore %% 23_06-06 %% %% } %% 23_06-06 %% %% if %% 23_06-06 %% B A' A Arrow %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (>) eq %% 23_06-06 %% { %% 23_06-06 %% %% gsave %% 23_06-06 %% %% A stranslate %% 23_06-06 %% %% A B pangle rotate %% 23_06-06 %% %% .5 .5 scale %% 23_06-06 %% %% arrow %% 23_06-06 %% %% grestore %% 23_06-06 %% A A' B Arrow %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (\() eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A stranslate %% 23_06-06 %% A B pangle rotate %% 23_06-06 %% O exclu %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (\)) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A stranslate %% 23_06-06 %% A B pangle 180 add rotate %% 23_06-06 %% O exclu %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (]) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A stranslate %% 23_06-06 %% A B pangle rotate %% 23_06-06 %% cr@chet %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option ([) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A stranslate %% 23_06-06 %% A B pangle 180 add rotate %% 23_06-06 %% cr@chet %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (o) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A circ %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% option (*) eq %% 23_06-06 %% { %% 23_06-06 %% gsave %% 23_06-06 %% A dot %% 23_06-06 %% grestore %% 23_06-06 %% } %% 23_06-06 %% if %% 23_06-06 %% end %% 23_06-06 %% } def %% 23_06-06 %% %% 23_06-06 %% %% Pour le moment, rien n'est prevu dans le format jps pour faire le %% 23_06-06 %% %% symbole d'exclusion d'un point sur une courbe. En attendant, on peut %% 23_06-06 %% %% faire un petit bricolage adapte au cas particulier voulu. %% 23_06-06 %% %% 23_06-06 %% /cr@chet { %% 23_06-06 %% gsave %% 23_06-06 %% [] 0 setdash %% 23_06-06 %% dotscale scale %% 23_06-06 %% dotangle rotate %% 23_06-06 %% newpath %% 23_06-06 %% -4 5 moveto %% 23_06-06 %% 4 0 rlineto %% 23_06-06 %% 0 -10 rlineto %% 23_06-06 %% -4 0 rlineto %% 23_06-06 %% stroke %% 23_06-06 %% grestore %% 23_06-06 %% } def %% 23_06-06 %% %% 23_06-06 %% %% syntaxe : x y exclu %% 23_06-06 %% /exclu { %% 23_06-06 %% gsave %% on encapsule les changements d'etat graphique %% 23_06-06 %% [] 0 setdash %% 23_06-06 %% 1 dict begin %% on rend locale la variable 'rayon' %% 23_06-06 %% %% en ouvrant un nouveau dictionnaire %% 23_06-06 %% stranslate %% on translate dans le repere jps pour %% 23_06-06 %% %% se mettre au point (x, y) %% 23_06-06 %% dotscale scale %% 23_06-06 %% newpath %% nouveau chemin %% 23_06-06 %% dotsize 2 div 0 dotsize .7 mul 90 -90 arc %% arc de cercle, centre (dotsize, 0) %% 23_06-06 %% stroke %% on encre le chemin %% 23_06-06 %% end %% on jette le dictionnaire %% 23_06-06 %% grestore %% on restore l'etat graphique %% 23_06-06 %% } def /lisere_arrow false def %% syntaxe : A B C D (-) gere_arrowhead /gere_arrowhead { 9 dict begin /option exch def /arrowpathend exch def /D defpoint /C defpoint /arrowpathstart exch def /B defpoint /A defpoint /i option length 1 sub def option length 1 gt { %% on separe l'option pour l'extremite gauche de l'option %% pour l'extremite droite option 0 get dup 45 eq %% c'est le '-' exch 61 eq %% c'est le '=' or { /option_gauche () def } { /option_gauche 1 string def option_gauche 0 option 0 get put } ifelse option i get dup 45 eq %% c'est le '-' exch 61 eq %% c'est le '=' or { /option_droite () def } { /option_droite 1 string def option_droite 0 option i get dup 60 eq {pop 62} { dup 62 eq {pop 60} { dup 40 eq {pop 41} { dup 41 eq {pop 40} { dup 91 eq {pop 93} { dup 93 eq {pop 91} if } ifelse } ifelse } ifelse } ifelse } ifelse put } ifelse A B arrowpathstart option_gauche arrowhead C D arrowpathend option_droite arrowhead } if end } def %% le dessin se fait en A, le segment venant de B %% syntaxe : B A (option) arrowhead /arrowhead { 4 dict begin /option exch def /arrowpathstart exch def /A defpoint /B defpoint option () eq {} if option (</style="color:green">) eq { gsave arrowpathstart draw_arrow % B 0 0 A Arrow grestore } if option (>) eq { arrowpathstart reversecpathobj gsave 2 dict begin dup cpathstartpoint /A defpoint dup cpathendpoint /B defpoint B A vecteur stranslate draw_arrow %% A 0 0 B Arrow end grestore } if option (\() eq { gsave A stranslate A B pangle rotate O exclu grestore } if option (\)) eq { gsave A stranslate A B pangle 180 add rotate O exclu grestore } if option (]) eq { gsave A stranslate A B pangle rotate cr@chet grestore } if option ([) eq { gsave A stranslate A B pangle 180 add rotate cr@chet grestore } if option (o) eq { gsave A circ grestore } if option (*) eq { gsave A dot grestore } if end } def %% Pour le moment, rien n'est prevu dans le format jps pour faire le %% symbole d'exclusion d'un point sur une courbe. En attendant, on peut %% faire un petit bricolage adapte au cas particulier voulu. /cr@chet { gsave [] 0 setdash dotscale scale dotangle rotate newpath -4 5 moveto 4 0 rlineto 0 -10 rlineto -4 0 rlineto stroke grestore } def %% syntaxe : x y exclu /exclu { gsave %% on encapsule les changements d'etat graphique [] 0 setdash 1 dict begin %% on rend locale la variable 'rayon' %% en ouvrant un nouveau dictionnaire stranslate %% on translate dans le repere jps pour %% se mettre au point (x, y) dotscale scale newpath %% nouveau chemin dotsize 2 div 0 dotsize .7 mul 90 -90 arc %% arc de cercle, centre (dotsize, 0) stroke %% on encre le chemin end %% on jette le dictionnaire grestore %% on restore l'etat graphique } def