%! % 12 octobre 2011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === Capture de commandes de systemdict -------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /LINETO { systemdict /lineto get exec } def /MOVETO { systemdict /moveto get exec } def /CURVETO { systemdict /curveto get exec } def /CLOSEPATH { systemdict /closepath get exec } def /RLINETO { systemdict /rlineto get exec } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === Transformation des commandes de construction des path(s) ---------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% 12/10/2011 : version incomplète et un peu brute ! /tx@anamorphosisPathDict 50 dict def tx@anamorphosisPathDict begin /moveto { /s@y ED /s@x ED /c@x s@x def /c@y s@y def s@x s@y Anamorphose MOVETO } bind def /lineto { /c@yt ED /c@xt ED /dx c@xt c@x sub 50 div def /dy c@yt c@y sub 50 div def 1 1 50 {dup dx mul c@x add exch dy mul c@y add Anamorphose LINETO} for /c@x c@xt def /c@y c@yt def } bind def /closepath { s@x s@y lineto CLOSEPATH } bind def /curveto { /c@yt ED /c@xt ED /c@yb ED /c@xb ED /c@ya ED /c@xa ED 1 1 20 { 20 div /s ED 1 s sub /t ED 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 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 Anamorphose LINETO } for /c@x c@xt def /c@y c@yt def } bind def /curvetoinv { /c@ya ED /c@xa ED /c@yb ED /c@xb ED /c@yt ED /c@xt ED 1 1 20 { 20 div /s ED 1 s sub /t ED 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 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 Anamorphose LINETO } for /c@x c@xt def /c@y c@yt def } bind def /rlineto { c@y add exch c@x add exch lineto } bind def end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === L'anamorphose cylindrique ----------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-cylindrical { /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def /a Xv Xp sub dup mul Yv Yp sub dup mul add def /b Xv Xp mul Yv Yp mul add Xv dup mul sub Yv dup mul sub def /c R neg Xv dup mul add Yv dup mul add def /d b dup mul a c mul sub 0.5 exp def /rho b neg d sub a div def /alpha 2 1 rho div sub def /xi Xv dup Xp sub rho mul sub def /yi Yv dup Yp sub rho mul sub def /k 2 Xv xi mul Yv yi mul add mul R div def /xv k xi mul Xv sub def /yv k yi mul Yv sub def xv dup xi sub alpha mul sub yv dup yi sub alpha mul sub } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === L'image est verticale -------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-cylindricalV { /Zp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def /a Xv Xp sub dup mul Yv dup mul add def /b Xv Xp mul Xv dup mul sub Yv dup mul sub def /c R neg Xv dup mul add Yv dup mul add def /d b dup mul a c mul sub 0.5 exp def /rho1 b neg d sub a div def /rho2 b neg d add a div def rho2 rho1 ge {/rho rho1 def}{/rho rho2 def} ifelse % /alpha 2 1 rho div sub Zv mul Zv Zp add div def /xi Xv dup Xp sub rho mul sub def /yi Yv 1 rho sub mul def /zi Zv dup Zp sub rho mul sub def /alpha 2 zi mul Zv sub zi Zv sub div def /k 2 Xv xi mul Yv yi mul add mul R div def /xv k xi mul Xv sub def /yv k yi mul Yv sub def xv dup xi sub alpha mul sub yv dup yi sub alpha mul sub } def %% === L'anamorphose conique --------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-conical { /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def /rP Xp dup mul Yp dup mul add 0.5 exp def /k Rmirror Zs Zv sub mul Zs rP mul Zv Rmirror mul sub div def /Xi k Xp mul def /Yi k Yp mul def k 0 eq {/Zi Zs def}{/Zi Zv 1 k sub mul def} ifelse /BETA rP Zv Atan def /THETA Rmirror Zs Atan def /ALPHA 90 2 THETA mul sub BETA add def /rI Xi dup mul Yi dup mul add 0.5 exp def /KP' Zi ALPHA sin ALPHA cos div div def /rP' rI KP' add def rP' Xp rP div mul rP' Yp rP div mul } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === L'anamorphose spherique --------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-spherical {% /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def /rV Xv dup mul Yv dup mul add Zv dup mul add def /rP Xp dup mul Yp dup mul add def /A rP rV add Xv Xp mul Yv Yp mul add 2 mul sub def /B rP neg Xv Xp mul add Yv Yp mul add def /C rP R sub def /Discriminant B dup mul A C mul sub 0.5 exp def /solution1 B neg Discriminant add A div def /solution2 B neg Discriminant sub A div def solution1 0 gt {/Coeff1 solution1 def}{/Coeff1 solution2 def} ifelse /Xi Xp 1 Coeff1 sub mul Coeff1 Xv mul add def /Yi Yp 1 Coeff1 sub mul Coeff1 Yv mul add def /Zi Coeff1 Zv mul def /Coeff2 2 Xv Xi mul Yv Yi mul add Zv Zi mul add mul R div def % k+2 /Xv2 Coeff2 Xi mul Xv sub def /Yv2 Coeff2 Yi mul Yv sub def /Zv2 Coeff2 Zi mul Zv sub def /Coeff3 Zi Zi Zv2 sub div def /Ximage Xi Coeff3 Xv2 Xi sub mul add def /Yimage Yi Coeff3 Yv2 Yi sub mul add def Ximage Yimage} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === La perspective --------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-perspective{ /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def Xp xD mul Yp ua add xD add div % x' ua yH xD add mul Yp yH mul add Yp ua add xD add div % y' } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === La perspective inversee -------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /pst-inverseperspective{ /Yp exch s@@y mul t@@y add def /Xp exch s@@x mul t@@x add def Xp ua yH sub mul Yp yH sub div % x' ua yH xD add mul ua xD add Yp mul sub Yp yH sub div % y' } def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% === Les commandes ----------------------------------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /Image { gsave /showpage {} def t@@x t@@y translate s@@x s@@y scale fichier run grestore } def