???
[pst-anamorphosis.git] / doc / pst-anamorphosis-add.tex
1 %% This work may be distributed and/or modified under the
2 %% conditions of the LaTeX Project Public License, either version 1.3
3 %% of this license or (at your option) any later version.
4 %% The latest version of this license is in
5 %% http://www.latex-project.org/lppl.txt
6 %% and version 1.3 or later is part of all distributions of LaTeX
7 %% version 2003/12/01 or later.
8
9 \csname PSTANAMORPHOSISAddLoaded\endcsname
10 \let\PSTANAMORPHOSISAddLoaded\endinput
11 % Requires some packages
12 \ifx\PSTANAMORPHOSISLoaded\endinput\else \input pst-anamorphosis \fi
13 \ifx\PSTnodesLoaded\endinput\else\input pst-node \fi
14 \ifx\MultidoLoaded\endinput\else \input multido.tex \fi
15 \ifx\PSTXKeyLoaded\endinput\else \input pst-xkey \fi
16 \def\fileversion{0.2}
17 \def\filedate{2011/10/13}
18 \message{`PSTANAMORPHOSISAdd' v\fileversion, \filedate}
19
20
21 \edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
22 \SpecialCoor
23 \psset{dimen=middle}
24 %
25 \pst@def{optionsanamorphosisAdd}<%
26 \psk@Anamorphose@translate
27 /t@@y exch unit def
28 /t@@x exch unit def
29 >
30
31 % Built from \psline
32 \def\pslineA{\pst@object{pslineA}}
33 \def\pslineA@i{%
34 \addto@pscode{
35 \tx@optionsanamorphosis
36 \tx@optionsanamorphosisAdd
37 }%
38 \pst@getarrows{%
39 \begin@OpenObj
40 \pst@getcoors[\pslineA@ii%
41 }%
42 }
43 \def\pslineA@ii{%
44 \ifx\pslinestyle\psls@@symbol\addto@pscode{ \psls@symbol SymbolLine }%
45 \else%
46 \addto@pscode{
47 ] /lespoints ED
48 /n1 lespoints length 2 div cvi def % nbre de points
49 /i 0 def
50 /TableauPoints [
51 n1 {
52 [ lespoints i get
53 lespoints i 1 add get
54 ]
55 /i i 2 add def
56 }repeat
57 ] def
58 % Tableau general des points
59 /TAB [
60 0 1 n1 2 sub {/i ED
61 TableauPoints i get aload pop
62 /Y1 ED /X1 ED
63 TableauPoints i 1 add get aload pop
64 /Y2 ED /X2 ED
65 0 0.005 1.0 { % k
66 /K exch def
67 [
68 K X2 mul 1 K sub X1 mul add
69 K Y2 mul 1 K sub Y1 mul add
70 tx@anamorphosisPathDict begin Anamorphose end
71 ]
72 } for
73 } for
74 ] def
75 /n2 TAB length def
76 [0 1 n2 1 sub {
77 /compteur exch def
78 TAB compteur get aload pop
79 } for
80 % \ifPst@noCurrentPoint\else\pst@cp\fi % current point?
81 \pslineA@iii % arc and lineto type
82 \tx@Line % .pro function
83 }%
84 \fi%
85 \end@OpenObj%
86 }
87 \def\pslineA@iii{
88 \ifdim\pslinearc>\z@
89 /r \pst@number\pslinearc def
90 /Lineto { \tx@Arcto } def
91 \else
92 /Lineto /lineto load def
93 \fi
94 \ifshowpoints true \else false \fi
95 \tx@setlinejoin %
96 }%
97 %
98 \def\pscircleA{\def\pst@par{}\pst@object{pscircleA}}
99 \def\pscircleA@i{\@ifnextchar({\pscircleA@do}{\pscircleA@do(0,0)}}
100 \def\pscircleA@do(#1)#2{%
101 \begin@ClosedObj
102 \pst@@getcoor{#1}%
103 \pssetlength\pst@dimc{#2}%
104 \def\pst@linetype{4}%
105 \addto@pscode{
106 \pst@coor /yC exch def /xC exch def
107 \ifPst@SpecialLength \pst@SpecialLength \else \pst@number\pst@dimc \fi
108 \psk@dimen CLW mul sub /rayon exch def
109 rayon xC add yC
110 tx@anamorphosisPathDict begin Anamorphose end
111 moveto
112 0 1 360 {/iA exch def
113 iA cos rayon mul xC add
114 iA sin rayon mul yC add
115 tx@anamorphosisPathDict begin Anamorphose end
116 lineto
117 } for
118 \ifPst@variableLW \pst@flattenpath \fi
119 closepath
120 }%
121 \showpointsfalse
122 \end@ClosedObj
123 }%
124 %
125 \def\psbezierA{\pst@object{psbezierA}}
126 \def\psbezierA@i{%
127 \addto@pscode{
128 \tx@optionsanamorphosis
129 \tx@optionsanamorphosisAdd
130 }
131 \pst@getarrows{%
132 \begin@OpenObj
133 \pst@getcoors[\psbezierA@ii%
134 }%
135 }
136 \def\psbezierA@ii{%
137 \addto@pscode{
138 ] /lespoints ED
139 [0 2 lespoints length 2 sub {/iP ED
140 lespoints iP get
141 lespoints iP 1 add get
142 tx@anamorphosisPathDict begin Anamorphose end
143 } for
144 \ifPst@noCurrentPoint\else\pst@cp\fi
145 \ifshowpoints true \else false \fi
146 \ifx\pslinestyle\psls@@symbol \psls@symbol OpenSymbolBezier
147 \else
148 \tx@OpenBezier
149 \ifshowpoints \tx@BezierShowPoints \fi
150 \fi
151 }%
152 \def\pst@linetype{1}%
153 \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
154 \end@OpenObj}
155 %
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 \def\pscurveA{\pst@object{pscurveA}}
158 \def\pscurveA@i{%
159 \addto@pscode{
160 \tx@optionsanamorphosis
161 \tx@optionsanamorphosisAdd
162 }
163 \pst@getarrows{%
164 \begin@OpenObj
165 \pst@getcoors[\pscurveA@ii% \pst@coors on stack
166 }%
167 }
168 \def\pscurveA@ii{%
169 \addto@pscode{
170 ] /lespoints ED
171 [0 2 lespoints length 2 sub {/iP ED
172 lespoints iP get
173 lespoints iP 1 add get
174 tx@anamorphosisPathDict begin Anamorphose end
175 } for
176 \ifPst@noCurrentPoint\else\pst@cp\fi % current point
177 \psk@curvature\space /c ED /b ED /a ED
178 \ifshowpoints true \else false \fi
179 \ifx\pslinestyle\psls@@symbol \psls@symbol OpenSymbolCurve \else \tx@OpenCurve \fi
180 \ifPst@variableLW \pst@flattenpath \fi
181 }%
182 \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
183 \end@OpenObj%
184 }
185 %
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
187 \def\psccurveA{\pst@object{psccurveA}}
188 \def\psccurveA@i{%
189 \addto@pscode{
190 \tx@optionsanamorphosis
191 \tx@optionsanamorphosisAdd
192 }
193 \pst@getarrows{%
194 \begin@OpenObj
195 \pst@getcoors[\psccurveA@ii% \pst@coors on stack
196 }%
197 }
198 \def\psccurveA@ii{%
199 \addto@pscode{
200 ] /lespoints ED
201 [0 2 lespoints length 2 sub {/iP ED
202 lespoints iP get
203 lespoints iP 1 add get
204 tx@anamorphosisPathDict begin Anamorphose end
205 } for
206 \ifPst@noCurrentPoint\else\pst@cp\fi % current point
207 \psk@curvature\space /c ED /b ED /a ED
208 \ifshowpoints true \else false \fi
209 \ifx\pslinestyle\psls@@symbol \psls@symbol ClosedSymbolCurve \else \tx@ClosedCurve \fi
210 \ifPst@variableLW \pst@flattenpath \fi
211 }%
212 \ifx\pslinestyle\psls@@symbol\def\pslinestyle{none}\fi%
213 \end@OpenObj%
214 }
215 %
216 \def\pnodeA{\def\pst@par{}\pst@object{pnodeA}}
217 \def\pnodeA@i(#1)#2{{%
218 \pst@@getcoor{#1}%
219 \pnode(!
220 \tx@optionsanamorphosis
221 \tx@optionsanamorphosisAdd
222 \pst@coor
223 tx@anamorphosisPathDict begin Anamorphose end
224 \pst@number\psyunit div exch
225 \pst@number\psxunit div exch
226 ){#2}}%
227 \ignorespaces%
228 }
229 %
230 \def\movetoA{\def\pst@par{}\pst@object{movetoA}}
231 \def\movetoA@i(#1){{%
232 \pst@@getcoor{#1}%
233 \addto@pscode{
234 \tx@optionsanamorphosis
235 \tx@optionsanamorphosisAdd
236 \pst@coor
237 tx@anamorphosisPathDict begin Anamorphose end
238 moveto}}}%
239 %
240 % choix de la police et de la taille des caracteres en cm !!
241 \define@key[psset]{pst-anamorphosis}{PSfont}{\def\pst@Anamorphose@PSfont{/#1 }}
242 \define@key[psset]{pst-anamorphosis}{fontsize}{\def\pst@Anamorphose@fontsize{#1 }}
243 %\define@key[psset]{pst-anamorphosis}{RotationAngleText}{\edef\psk@Anamorphose@RotationAngleText{#1 }}%
244 \psset[pst-anamorphosis]{PSfont=Times-Roman,fontsize=35}%,RotationAngleText=0}
245
246 \def\pstextA{\def\pst@par{}\pst@object{pstextA}}
247 \def\pstextA@i{\@ifnextchar({\pstextA@do}{\pstextA@do(0,0)}}
248 \def\pstextA@do(#1)#2{% #2 = texte à transformer
249 \begingroup%
250 \begin@SpecialObj%
251 \pst@@getcoor{#1}%
252 \addto@pscode{
253 \pst@coor /t@@y ED /t@@x ED % Translate
254 \tx@optionsanamorphosis
255 /fontsize {\pst@Anamorphose@fontsize } bind def
256 /PSfont {\pst@Anamorphose@PSfont} def
257 %/RotationAngleText \psk@Anamorphose@RotationAngleText def
258 %% D'après un fichier original de
259 %%(c) P. Kleiweg 1997
260 %% adapté par :
261 %% Manuel Luque
262 %% Arnaud Schmittbuhl
263 %% Jean-Paul Vignault
264 %% les commentaires sont de Jean-Paul Vignault
265 %% juin 2006
266 %% Caractères accentués
267 /ReEncode { exch findfont
268 dup length dict begin { 1 index /FID eq {pop pop} {def} ifelse
269 }forall /Encoding ISOLatin1Encoding def currentdict end definefont
270 pop }bind def
271 /Font PSfont /ISOfont ReEncode /ISOfont def
272 %% decalage en picas du texte en
273 %% dessous de la ligne y=0
274 %% la procedure de base pour la transformation des points du chemin
275 /warp {
276 3 dict begin
277 tx@anamorphosisPathDict begin Anamorphose end
278 end
279 } bind def
280 %% pour remplacer 'move'
281 /warpmove{
282 %% on teste le booleen place 2 tokens plus en avant sur la pile
283 %% si c'est 'true', alors on en est au 1er appel => on initialise
284 %% le chemin
285 2 index {
286 newpath
287 } if
288 %% puis on applique warp a notre point
289 warp moveto
290 %% on enleve le 'true' pour mettre un 'false' a la place
291 pop false
292 } bind def
293 %% pour remplacer 'lineto
294 /warpline {
295 warp lineto
296 } bind def
297 %% pour remplacer 'curveto'
298 /warpcurve {
299 6 2 roll warp
300 6 2 roll warp
301 6 2 roll warp
302 curveto
303 } bind def
304 %% 'warpit' declenche la transformation du chemin courant
305 /warpit {
306 true
307 { warpmove } { warpline } { warpcurve } { closepath } pathforall
308 pop
309 } bind def
310 %% definition des differentes constantes
311 % taille de des caracteres
312 Font findfont fontsize scalefont setfont
313 /warptxt (#2) def % texte a deformer
314 /warpwidth warptxt stringwidth pop def % largeur horizontale du texte
315 /warphalf warpwidth 2 div def % demi-largeur horizontale
316 %% le chemin constitue avec la chaine de caracteres
317 warptxt warphalf neg 0 moveto %% on se deplace (init chemin)
318 true charpath %% on cree le chemin
319 %% maintenant on y va
320 warpit %% on applique le pathforall
321 gsave
322 \pst@usecolor\psfillcolor
323 fill
324 grestore
325 stroke
326 \ifPst@Anamorphose@image
327 % le texte dans le cercle
328 t@@x t@@y translate
329 s@@x s@@y scale
330 warptxt warphalf neg 0 moveto %% on se deplace (init chemin)
331 true charpath
332 gsave
333 \pst@usecolor\psfillcolor
334 fill
335 grestore
336 stroke
337 \fi
338 }%
339 \end@SpecialObj%
340 \endgroup%
341 }
342
343
344
345 %% =============================================================================
346 %% AFP : Anamorphose à partir d'un Fichier PST.
347 %% Le code de pscustom est évalué après reroutage de la macro. Il est exécuté
348 %% dans le contexte tx@anamorphosisPathDict
349 %% =============================================================================
350 %% Début et Fin
351 \def\pst@begin@AFP{\xdef\pst@code{\pst@code
352 tx@anamorphosisPathDict begin
353 \tx@optionsanamorphosis
354 \tx@optionsanamorphosisAdd\space}}
355 \def\pst@end@AFP{\xdef\pst@code{\pst@code end\space}}
356 %% pscustom adapté à la tâche
357 \def\pscustomAFP{\def\pst@par{}\pst@object{pscustomAFP}}
358 \long\def\pscustomAFP@i#1{%
359 \begin@SpecialObj%
360 \pst@begin@AFP%
361 \the\pst@customAFPdefs
362 \setbox\pst@hbox=\hbox{#1}%
363 \psk@fillstyle%
364 \pst@stroke%
365 \pst@end@AFP%
366 \end@SpecialObj}
367 %% pscustomdefs associé
368 \newtoks\pst@customAFPdefs
369 \pst@customAFPdefs{%
370 \def\moveto(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor moveto}}%
371 \def\psline(#1){\pst@@getcoor{#1}\addto@pscode{\pst@coor lineto}}%
372 \def\closepath{\addto@pscode{closepath}}%
373 \def\newpath{\addto@pscode{newpath}}%
374 \def\stroke{\def\pst@par{}\pst@object{stroke}}%
375 \def\fill{\def\pst@par{}\pst@object{fill}}%
376 }
377 \def\AFP#1{%
378 \begingroup
379 \def\curvetoinv{\pst@getcoors{\space}\fcurvetoinv}
380 \def\fcurvetoinv{\addto@pscode{curvetoinv}}
381 \let\SAUVEpscustom\pscustom
382 \let\SAUVEpsbezier\psbezier
383 \let\pscustom\pscustomAFP
384 \let\psbezier\curvetoinv
385 \input{#1}
386 \let\psbezier\SAUVEpsbezier
387 \let\pscustom\SAUVEpscustom
388 \endgroup%
389 }%
390 %%%% Fin de AFP %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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.