???
[pst-anamorphosis.git] / doc / anamorphosis.pro
1 %!
2 % 12 octobre 2011
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %% === Capture de commandes de systemdict --------------------------------------
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 /LINETO    { systemdict /lineto get exec    } def
7 /MOVETO    { systemdict /moveto get exec    } def
8 /CURVETO   { systemdict /curveto get exec   } def
9 /CLOSEPATH { systemdict /closepath get exec } def
10 /RLINETO   { systemdict /rlineto get exec   } def
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %% === Transformation des commandes de construction des path(s) ----------------
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %% 12/10/2011 : version incomplète et un peu brute !
15 /tx@anamorphosisPathDict 50 dict def tx@anamorphosisPathDict begin
16 /moveto {
17   /s@y ED /s@x ED /c@x s@x def /c@y s@y def
18   s@x s@y Anamorphose MOVETO
19 } bind def
20 /lineto {
21   /c@yt ED /c@xt ED /dx c@xt c@x sub 50 div def /dy c@yt c@y sub 50 div def
22   1 1 50 {dup dx mul c@x add exch dy mul c@y add Anamorphose LINETO} for
23   /c@x c@xt def /c@y c@yt def
24 } bind def
25 /closepath {
26   s@x s@y lineto CLOSEPATH
27 } bind def
28 /curveto {
29   /c@yt ED /c@xt ED
30   /c@yb ED /c@xb ED
31   /c@ya ED /c@xa ED
32   1 1 20 {
33     20 div /s ED 1 s sub /t ED
34     t c@x mul 3 s c@xa mul mul add t mul 3 s s c@xb mul mul mul add t mul s 3 exp c@xt mul add
35     t c@y mul 3 s c@ya mul mul add t mul 3 s s c@yb mul mul mul add t mul s 3 exp c@yt mul add
36     Anamorphose LINETO
37   } for
38   /c@x c@xt def /c@y c@yt def
39 } bind def
40 /curvetoinv {
41   /c@ya ED /c@xa ED
42   /c@yb ED /c@xb ED
43   /c@yt ED /c@xt ED
44   1 1 20 {
45     20 div /s ED 1 s sub /t ED
46     t c@x mul 3 s c@xa mul mul add t mul 3 s s c@xb mul mul mul add t mul s 3 exp c@xt mul add
47     t c@y mul 3 s c@ya mul mul add t mul 3 s s c@yb mul mul mul add t mul s 3 exp c@yt mul add
48     Anamorphose LINETO
49   } for
50   /c@x c@xt def /c@y c@yt def
51 } bind def
52 /rlineto {
53   c@y add exch c@x add exch lineto
54 } bind def
55 end
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %% === L'anamorphose cylindrique -----------------------------------------------
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 /pst-cylindrical {
60   /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
61   /a Xv Xp sub dup mul Yv Yp sub dup mul add def
62   /b Xv Xp mul Yv Yp mul add Xv dup mul sub Yv dup mul sub def
63   /c R neg Xv dup mul add Yv dup mul add def
64   /d b dup mul a c mul sub 0.5 exp def
65   /rho b neg d sub a div def
66   /alpha 2 1 rho div sub def
67   /xi Xv dup Xp sub rho mul sub def
68   /yi Yv dup Yp sub rho mul sub def
69   /k 2 Xv xi mul Yv yi mul add mul R div def
70   /xv k xi mul Xv sub def
71   /yv k yi mul Yv sub def
72   xv dup xi sub alpha mul sub
73   yv dup yi sub alpha mul sub
74 } def
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %% === L'image est verticale --------------------------------------------------
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
78 /pst-cylindricalV {
79   /Zp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
80   /a Xv Xp sub dup mul Yv dup mul add def
81   /b Xv Xp mul Xv dup mul sub Yv dup mul sub def
82   /c R neg Xv dup mul add Yv dup mul add def
83   /d b dup mul a c mul sub 0.5 exp def
84   /rho1 b neg d sub a div def
85   /rho2 b neg d add a div def
86   rho2 rho1 ge {/rho rho1 def}{/rho rho2 def} ifelse
87 %  /alpha 2 1 rho div sub Zv mul Zv Zp add div def
88   /xi Xv dup Xp sub rho mul sub def
89   /yi Yv 1 rho sub mul def
90   /zi Zv dup Zp sub rho mul sub def
91   /alpha 2 zi mul Zv sub zi Zv sub div def
92   /k 2 Xv xi mul Yv yi mul add mul R div def
93   /xv k xi mul Xv sub def
94   /yv k yi mul Yv sub def
95   xv dup xi sub alpha mul sub
96   yv dup yi sub alpha mul sub
97 } def
98 %% === L'anamorphose conique ---------------------------------------------------
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 /pst-conical {
101   /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
102   /rP Xp dup mul Yp dup mul add 0.5 exp def
103   /k Rmirror Zs Zv sub mul Zs rP mul Zv Rmirror mul sub div def
104   /Xi k Xp mul def
105   /Yi k Yp mul def
106   k 0 eq {/Zi Zs def}{/Zi Zv 1 k sub mul def} ifelse
107   /BETA rP Zv Atan def
108   /THETA Rmirror Zs Atan def
109   /ALPHA 90 2 THETA mul sub BETA add def
110   /rI Xi dup mul Yi dup mul add 0.5 exp def
111   /KP' Zi ALPHA sin ALPHA cos div div def
112   /rP' rI KP' add def
113   rP' Xp rP div mul
114   rP' Yp rP div mul
115 } def
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 %% === L'anamorphose spherique ---------------------------------------------------
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 /pst-spherical {%
120     /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
121     /rV Xv dup mul Yv dup mul add Zv dup mul add def
122     /rP Xp dup mul Yp dup mul add def
123     /A rP rV add Xv Xp mul Yv Yp mul add 2 mul sub def
124     /B rP neg Xv Xp mul add Yv Yp mul add def
125     /C rP R sub def
126     /Discriminant B dup mul A C mul sub 0.5 exp def
127     /solution1 B neg Discriminant add
128             A div def
129     /solution2 B neg Discriminant sub
130             A div def
131     solution1 0 gt {/Coeff1 solution1 def}{/Coeff1 solution2 def}
132     ifelse
133     /Xi Xp 1 Coeff1 sub mul Coeff1 Xv mul add def
134     /Yi Yp 1 Coeff1 sub mul Coeff1 Yv mul add def
135     /Zi Coeff1 Zv mul def
136     /Coeff2 2 Xv Xi mul Yv Yi mul add Zv Zi mul add mul R div def % k+2
137     /Xv2 Coeff2 Xi mul Xv sub def
138     /Yv2 Coeff2 Yi mul Yv sub def
139     /Zv2 Coeff2 Zi mul Zv sub def
140     /Coeff3 Zi Zi Zv2 sub div def
141     /Ximage Xi Coeff3 Xv2 Xi sub mul add def
142     /Yimage Yi Coeff3 Yv2 Yi sub mul add def
143     Ximage Yimage}
144     def
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 %% === La perspective ---------------------------------------------------
147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 /pst-perspective{
149   /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
150        Xp xD mul
151        Yp ua add xD add div % x'
152        ua yH xD add mul Yp yH mul add
153       Yp ua add xD add div  % y'
154    } def
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156 %% === La perspective inversee --------------------------------------------------
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 /pst-inverseperspective{
159   /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def
160        Xp ua yH sub mul
161        Yp yH sub div   % x'
162        ua yH xD add mul ua xD add Yp mul sub
163        Yp  yH sub div  % y'
164    } def
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 %% === Les commandes -----------------------------------------------------------
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 /Image {
169   gsave
170     /showpage {} def
171     t@@x t@@y translate s@@x s@@y scale
172     fichier run
173   grestore
174 } def

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.