home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / text / tex / pastex / source / dvips / special.lpro < prev    next >
Encoding:
Text File  |  1994-09-18  |  8.3 KB  |  335 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%     header for the \special command
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. %   The structure of the PostScript produced by dvips for \special is:
  5. %         @beginspecial
  6. %           - any number of @hsize, @hoffset, @hscale, etc., commands
  7. %         @setspecial
  8. %           - the user's file of PostScript commands
  9. %         @endspecial
  10.  
  11. TeXDict begin
  12. /SDict 200 dict N
  13. SDict begin
  14.  
  15. /@SpecialDefaults
  16.   { /hs 612 N
  17.     /vs 792 N
  18.     /ho 0 N
  19.     /vo 0 N
  20.     /hsc 1 N
  21.     /vsc 1 N
  22.     /ang 0 N
  23.     /CLIP 0 N
  24.     /rwiSeen false N
  25.     /rhiSeen false N
  26.     /letter {} N /note {} N /a4 {} N /legal {} N
  27.   } B
  28.  
  29. %
  30. %   The following definition sets up the units that hscale/vscale are in.
  31. %   For certain sites this might require change, but it is
  32. %   recommended instead that any macro packages that require
  33. %   hscale/vscale set the units appropriately via
  34. %
  35. %   \special{! /@scaleunit 1 def }
  36. %
  37. %   if global, or
  38. %
  39. %   \special{" /@scaleunit 1 def }
  40. %
  41. %   before each instance if multiple macro packages with
  42. %   different requirements are being used.
  43. %
  44. /@scaleunit 100 N
  45. %       s @hscale  -    set scale factor
  46. /@hscale {@scaleunit div /hsc X} B
  47. /@vscale {@scaleunit div /vsc X} B
  48. /@scale {dup /hsc X /vsc X} B % added by G. Ghibo` (26-Jun-94)
  49.  
  50. %       d @hsize   -    specify a horizontal clipping dimension
  51. /@hsize {/hs X /CLIP 1 N} B
  52. /@vsize {/vs X /CLIP 1 N} B
  53.  
  54. /@clip {/CLIP 2 N} B
  55.  
  56. %       d @hoffset -    specify a shift for the figure
  57. /@hoffset {/ho X} B
  58. /@voffset {/vo X} B
  59.  
  60. %       a @angle   -    set rotation angle
  61. /@angle {/ang X} B
  62.  
  63. %
  64. %   Here we handle bounding box calculations, if necessary.
  65. %
  66. /@rwi { 10 div /rwi X /rwiSeen true N } B % rwi will be real width after scaling
  67. /@rhi { 10 div /rhi X /rhiSeen true N } B % rhi will be real height after scaling
  68. /@llx { /llx X } B
  69. /@lly { /lly X } B
  70. /@urx { /urx X } B
  71. /@ury { /ury X } B
  72.  
  73. /magscale true def
  74.  
  75. end % of SDict
  76.  
  77. /@MacSetUp
  78.   { userdict /md known  % if md is defined
  79.       { userdict /md get type /dicttype eq      % and if it is a dictionary
  80.     {
  81.         userdict begin                       % expand it if necessary
  82.            md length 10 add md maxlength ge
  83.            {/md md dup length 20 add dict copy def}if
  84.         end
  85.     md begin                             % then redefine some stuff
  86.     /letter {} N
  87.     /note {} N
  88.     /legal {} N
  89.     /od{txpose
  90.         1 0 mtx defaultmatrix dtransform S atan/pa X
  91.         newpath clippath mark
  92.         {transform{itransform moveto}}
  93.         {transform{itransform lineto}}
  94.         { 6 -2 roll transform
  95.           6 -2 roll transform
  96.           6 -2 roll transform
  97.           { itransform 6 2 roll
  98.         itransform 6 2 roll
  99.         itransform 6 2 roll
  100.         curveto
  101.           }
  102.         }
  103.         {{closepath}}
  104.         pathforall newpath counttomark array astore /gc xdf
  105.         pop ct 39 0 put
  106.         10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
  107.     }N
  108.     /txpose{
  109.         pxs pys scale ppr aload pop
  110.         por {
  111.         noflips {
  112.             pop S neg S TR pop 1 -1 scale
  113.         }if
  114.         xflip yflip and {
  115.             pop S neg S TR 180 rotate 1 -1 scale
  116.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  117.             ppr 0 get neg sub neg TR
  118.         }if 
  119.         xflip yflip not and {
  120.             pop S neg S TR pop 180 rotate
  121.             ppr 3 get ppr 1 get neg sub neg 0 TR
  122.         }if
  123.         yflip xflip not and {
  124.             ppr 1 get neg ppr 0 get neg TR
  125.         }if
  126.         }
  127.         {
  128.         noflips {
  129.             TR pop pop 270 rotate 1 -1 scale
  130.         }if
  131.         xflip yflip and {
  132.             TR pop pop 90 rotate 1 -1 scale
  133.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  134.             ppr 0 get neg sub neg TR
  135.         }if
  136.         xflip yflip not and {
  137.             TR pop pop 90 rotate ppr 3 get
  138.             ppr 1 get neg sub neg 0 TR
  139.         }if
  140.         yflip xflip not and {
  141.             TR pop pop 270 rotate ppr 2 get
  142.             ppr 0 get neg sub neg 0 S TR
  143.         }if
  144.         }ifelse
  145.         scaleby96 {
  146.         ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
  147.         TR .96 dup scale neg S neg S TR
  148.         }if
  149.     }N
  150.     /cp {pop pop showpage pm restore}N
  151.         end
  152.       }if
  153.     } if    
  154.   } N
  155.  
  156. %
  157. %   The following procedure brings us back to PostScript size.  It takes
  158. %   into account the current global dvi magnification, so graphics
  159. %   scale with the document.
  160. %
  161. /normalscale {
  162.     Resolution 72 div VResolution 72 div neg scale
  163.     magscale { DVImag dup scale } if
  164.     0 setgray
  165. } N
  166. %
  167. %   We need the psfig macros.
  168. %
  169. % All software, documentation, and related files in this distribution of
  170. % psfig/tex are Copyright (c) 1987 Trevor J. Darrell
  171. %
  172. % Permission is granted for use and non-profit distribution of psfig/tex 
  173. % providing that this notice be clearly maintained, but the right to
  174. % distribute any portion of psfig/tex for profit or as part of any commercial
  175. % product is specifically reserved for the author.
  176. %
  177. %
  178. % psfigTeX PostScript Prolog
  179. % $Header: /usr/local/src/TeX/Dvips-5.0.2/RCS/special.lpro,v 1.1 90/03/10 20:32:57 grunwald Exp $
  180. %
  181. /psfts { S 65781.76 div N } N
  182.  
  183. %  x y bb-llx bb-lly bb-urx bb-ury startFig -
  184. /startTexFig {
  185.     /psf$SavedState save N
  186.     userdict maxlength dict begin
  187.  
  188.     /magscale true def
  189.     normalscale
  190.         currentpoint TR    %set the current point as the user's origin
  191.  
  192.     /psf$ury psfts
  193.     /psf$urx psfts
  194.     /psf$lly psfts
  195.     /psf$llx psfts
  196.     /psf$y psfts
  197.     /psf$x psfts
  198.     
  199.     currentpoint /psf$cy X /psf$cx X
  200.  
  201.     /psf$sx psf$x psf$urx psf$llx sub div N     % scaling for x
  202.     /psf$sy psf$y psf$ury psf$lly sub div N    % scaling for y
  203.  
  204.     psf$sx psf$sy scale            % scale by (sx,sy)
  205.  
  206.     psf$cx psf$sx div psf$llx sub
  207.     psf$cy psf$sy div psf$ury sub TR
  208.     
  209.     /showpage {
  210.     } N
  211.     /erasepage {
  212.     } N
  213.     /copypage {
  214.     } N
  215.         /p 3 def % necessary to get around a bug in Adobe Illustrator
  216.     @MacSetUp
  217. } N
  218.  
  219. % llx lly urx ury doclip -    (args in figure coordinates)
  220. /doclip {
  221.         psf$llx psf$lly psf$urx psf$ury
  222.     currentpoint 6 2 roll
  223.     newpath 4 copy
  224.     4 2 roll moveto
  225.     6 -1 roll S lineto
  226.     S lineto
  227.     S lineto
  228.     closepath clip
  229.     newpath
  230.     moveto
  231. } N
  232. % - endTexFig -
  233. /endTexFig { end psf$SavedState restore } N
  234.  
  235. % this will be invoked as the result of a \special command (for the
  236. % inclusion of PostScript graphics).  The basic idea is to change all
  237. % scaling and graphics back to defaults, but to shift the origin
  238. % to the current position on the page.
  239.  
  240. /@beginspecial          % - @beginspecial -     -- enter special mode
  241.   { SDict begin
  242.     /SpecialSave save N
  243.     gsave
  244.     normalscale
  245.     currentpoint TR    %set the current point as the user's origin
  246.     @SpecialDefaults    % setup default offsets, scales, sizes, and angle
  247.     count /ocount X /dcount countdictstack N
  248.   } N
  249.  
  250. /@setspecial    % to setup user specified offsets, scales, sizes (for clipping)
  251.   {
  252.     CLIP 1 eq
  253.       { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto 
  254.         closepath clip }
  255.     if
  256.     ho vo TR
  257.     hsc vsc scale
  258.     ang rotate
  259.     rwiSeen {
  260.        rwi urx llx sub div
  261.        rhiSeen { rhi ury lly sub div } { dup } ifelse
  262.        scale llx neg lly neg TR
  263.     } {
  264.        rhiSeen { rhi ury lly sub div dup scale llx neg lly neg TR } if
  265.     } ifelse
  266.     CLIP 2 eq
  267.     { newpath llx lly moveto urx lly lineto urx ury lineto llx ury lineto
  268.       closepath clip }
  269.     if
  270.     /showpage {} N
  271.     /erasepage {} N
  272.     /copypage {} N
  273.     newpath
  274.   } N
  275.  
  276. /@endspecial            % - @endspecial -       -- leave special mode
  277.   { count ocount sub {pop} repeat
  278.     countdictstack dcount sub {end} repeat
  279.     grestore SpecialSave restore
  280.     end
  281.   } N
  282. /@defspecial
  283.   {
  284.     SDict begin
  285.   } N
  286. /@fedspecial
  287.   {
  288.     end
  289.   } B
  290.  
  291. %%% macros for tpic
  292. /li             % x y li -              -- draw line to
  293.   { lineto
  294.   } B
  295.  
  296. /rl             % dx dy rl -            -- draw relative line
  297.   { rlineto
  298.   } B
  299.  
  300. /rc             % x0 y0 x1 y1 y2 y2 rc  -- draw bezier curve
  301.   { rcurveto
  302.   } B
  303.  
  304. /np        % np -            -- start a new path and save currentpoint
  305.   { /SaveX currentpoint /SaveY X N   % remember current point
  306.     1 setlinecap
  307.     newpath
  308.   } N
  309.  
  310. /st             % st -                  -- draw the last path and restore currentpoint
  311.   { stroke
  312.     SaveX SaveY moveto                  % restore the current point
  313.   } N
  314.  
  315. /fil             % fil                    -- fill the last path and restore currentpoint
  316.   { fill
  317.     SaveX SaveY moveto                  % restore the current point
  318.   } N
  319.  
  320. /ellipse        % xc yc xrad yrad startAngle endAngle ellipse
  321.     {
  322.         /endangle X
  323.         /startangle X
  324.         /yrad X
  325.         /xrad X
  326.  
  327.         /savematrix matrix currentmatrix N
  328.  
  329.         TR xrad yrad scale
  330.         0 0 1 startangle endangle arc
  331.         savematrix setmatrix
  332.     } N
  333. %%% end of macros for tpic
  334. end                     % revert to previous dictionary
  335.