home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 49 / PCPP49b.iso / freebies / BeOS5-PersonalEdition / data1.cab / Data_Files / image.be / beos / system / add-ons / Print / Header < prev    next >
Encoding:
Text File  |  2000-03-24  |  3.2 KB  |  209 lines

  1.  
  2. % Useful definitions
  3.  
  4. /d    { def } bind def
  5. /bd { bind def } bind d
  6. /xd { exch def } bd
  7. /_cl 0 d
  8.  
  9. % Variables init
  10.  
  11. /_fs 32 d
  12. /_fn /Courier_New d
  13. /_fh 0. d
  14. /_fsh 90. d
  15. /_fr 0. d
  16.  
  17. % shortcuts for postscript operators
  18.  
  19. /p {newpath} bd
  20. /gs {gsave} bd
  21. /gr {grestore} bd
  22. /cp {closepath} bd
  23. /m {moveto} bd
  24. /l {lineto} bd
  25. /s {currentpoint stroke m} bd
  26. /sp {currentpoint strokepath m} bd
  27. /f {currentpoint fill m} bd
  28. /w {setlinewidth} bd
  29. /c {setrgbcolor} bd
  30. /g {setgray} bd
  31. /t {translate} bd
  32. /r {rotate} bd
  33. /sc {scale} bd
  34.  
  35. % Set font name
  36. /fn {exch {findfont scalefont setfont}} bd
  37.  
  38. % Set font size
  39. /fs {    /_fs xd
  40.         90 _fsh sub 45. div _fs mul/_fh xd
  41. } bd
  42.  
  43. % Set font rotation
  44. /fr {/_fr xd } bd
  45.  
  46. % Set font shear
  47. /fh {/_fh xd } bd
  48.  
  49. % Draw String
  50. /sh_dict 4 dict d
  51. sh_dict /mtrx matrix put
  52. /sh {
  53.         sh_dict begin
  54.         
  55.         
  56.         /_req xd
  57.         dup stringwidth pop /_got xd
  58.         
  59.         _got _req mul 0 ne {
  60.             /savematrix mtrx currentmatrix d
  61.             currentpoint translate                % 0,0 is origin
  62.             _fr rotate                            % rotate
  63.             _req _got div 1. scale                % scale to get exact string length
  64.             _cl 0 eq { 
  65.                 show                            % draw string which is on the stack
  66.             } {
  67.                 true charpath                    % obtain path for clipping
  68.             } ifelse
  69.             savematrix setmatrix
  70.         } if
  71.  
  72.         end        
  73. } bd
  74.  
  75. % definition of patterning for alternate patterns modes
  76. %
  77. /PaintPat {
  78.     0 0 moveto    
  79.     0 1 lineto
  80.     1 1 lineto
  81.     1 0 lineto
  82.     closepath
  83.     fill
  84. } bd
  85.  
  86. /CreatePattern {
  87.         /PatternImage xd
  88.         20 dict begin    
  89.         /PaintType 2 d
  90.         /PatternType 1 d
  91.         /TilingType 1 d
  92.         /BBox [0 0 8 8] d
  93.         /XStep 8 d
  94.         /YStep 8 d
  95.         /PaintProc {
  96.             pop
  97.             /_y 0 d
  98.             /_index 0 d    
  99.             8 {  
  100.                 /_x 0 d
  101.             8     {    gs
  102.                      _x _y translate PatternImage _index get 1 eq {PaintPat} if 
  103.                     gr
  104.                      _index 1 add /_index xd
  105.                      _x 1 add /_x xd
  106.                 } repeat 
  107.                 _y 1 add /_y xd
  108.             } repeat
  109.         } d
  110.         currentdict end
  111.         matrix
  112.         makepattern
  113.         /CurPattern xd
  114. } bd
  115.  
  116.  
  117. % Common rectangle : left top right bottom r_po
  118. /r_po {
  119.     0 begin
  120.     /_b xd
  121.     /_r xd
  122.     /_t xd
  123.     /_l xd 
  124.  
  125.     _l _t m
  126.     _r _t lineto
  127.     _r _b lineto
  128.     _l _b lineto
  129.     cp
  130.     end
  131. } bd
  132. /r_po load 0 4 dict put
  133.  
  134. % Create an arc inside rect defined by left top width height
  135.  
  136. /a_po_dict 8 dict d
  137. a_po_dict /mtrx matrix put
  138.  
  139. /a_po {
  140.     a_po_dict begin
  141.     /endangle xd
  142.     /startangle xd
  143.     /yrad xd
  144.     /xrad xd
  145.     /y xd
  146.     /x xd
  147.     
  148.     /savematrix mtrx currentmatrix d
  149.     x y t
  150.     xrad yrad sc
  151.     startangle r
  152.     1 0 m
  153.     0 0 1 0 endangle startangle sub arc
  154.     savematrix setmatrix
  155.  
  156.     end
  157. } bd
  158.  
  159. % Create an rounded rect defined by xRadius yRadius width height left top 
  160.  
  161. /rr_po_dict 6 dict d
  162. rr_po_dict /mtrx matrix put
  163. /rr_po {
  164.     rr_po_dict begin
  165.  
  166.     /savematrix mtrx currentmatrix d
  167.  
  168.     t    % use left / top
  169.     
  170.     dup /_h xd
  171.     exch dup /_w xd
  172.     exch
  173.     
  174.     sc            % use width / height
  175.  
  176.     _h div neg /_yRadius xd
  177.     _w div /_xRadius xd
  178.  
  179.     /_fl 2. d
  180.     
  181.     0.                             _yRadius                  m
  182.     0.                             1. _yRadius sub         lineto
  183.     0.                            1. _yRadius _fl div sub
  184.     _xRadius _fl div            1.
  185.     _xRadius                     1.                         curveto
  186.     1. _xRadius sub             1.                         lineto
  187.     1. _xRadius _fl div sub     1.    
  188.     1.                             1. _yRadius _fl div sub    
  189.     1.                             1. _yRadius sub         curveto
  190.     1.                             _yRadius                 lineto
  191.     1.                             _yRadius _fl div
  192.     1. _xRadius _fl div sub     0.     
  193.     1. _xRadius sub             0.                         curveto
  194.     _xRadius                     0.                         lineto
  195.     _xRadius _fl div             0. 
  196.     0.                             _yRadius _fl div
  197.     0.                             _yRadius                  curveto
  198.  
  199.     cp
  200.     
  201.     savematrix setmatrix
  202.     
  203.     end
  204. } bd
  205.  
  206.  
  207. % End of procset
  208.  
  209.