home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3035 < prev    next >
Internet Message Format  |  1991-03-08  |  6KB

  1. From: jwz@lucid.com (Jamie Zawinski)
  2. Newsgroups: comp.lang.postscript,alt.sources
  3. Subject: video-tape.ps v2.0
  4. Message-ID: <JWZ.91Mar6191119@sunvalleymall.lucid.com>
  5. Date: 7 Mar 91 00:11:19 GMT
  6.  
  7. %!PS-Adobe-1
  8. %%Creator: Jamie Zawinski <jwz@lucid.com>
  9. %%Title: video-tape.ps
  10. %%CreationDate: 1-mar-91
  11. %%
  12. %%  PostScript code to generate VHS video cassette labels.  Version 2.0.
  13. %%  Copyright (c) 1991 Jamie Zawinski <jwz@lucid.com>.  Comments welcome.
  14. %%
  15. %%  Permission granted for non-commercial use and distribution so long as
  16. %%  this notice of copyright remains intact.
  17. %%
  18. %%  There are examples of how to use this code at the end of this file.
  19. %%
  20. %%  I find that rubber cement works best for attaching these labels to
  21. %%  video cassettes.  A water-based glue or epoxy will cause the paper
  22. %%  to warp eventually.
  23. %%
  24. %%EndComments
  25.  
  26. % Set this to any (short) string you like.
  27. /ID (JWZ) def
  28. /side-font   /Helvetica-Bold def
  29. /top-font    /Helvetica-Bold def
  30. /header-font /Helvetica-Bold def
  31. /number-font /Helvetica-Bold def
  32.  
  33. % swap the values of FG and BG if you want black-on-white.
  34. /FG 1   def
  35. /MG 0.5 def
  36. /BG 0   def
  37.  
  38. /bdef { bind readonly def } bind readonly def
  39.  
  40. /box {
  41.   4 2 roll
  42.   newpath moveto
  43.     exch dup 0 rlineto
  44.     exch 0 exch neg rlineto
  45.     neg 0 rlineto
  46.   closepath
  47. } bdef
  48.  
  49. /rightshow
  50.  {dup stringwidth pop
  51.   neg 0 rmoveto
  52.   show } bdef
  53.  
  54. /centershow
  55.  {dup stringwidth pop
  56.   2 div neg 0 rmoveto
  57.   show } bdef
  58.  
  59. /inch { 72 mul } bdef
  60.  
  61. /internal-draw-side-label {
  62.   gsave
  63.     1 setlinejoin
  64.     MG setgray
  65.     0 0 5.75 inch 0.75 inch  box fill
  66.     0 setgray
  67.     0 0 5.75 inch  0.75 inch  box stroke
  68.     BG setgray
  69.     1 inch -0.1 inch  4.25 inch 0.55 inch box fill
  70.     0.1 inch -0.1 inch  0.25 inch 0.55 inch box fill
  71.     FG setgray
  72.     1 inch -0.1 inch  4.25 inch 0.55 inch box stroke
  73.     0.1 inch -0.1 inch  0.25 inch 0.55 inch box stroke
  74.     gsave
  75.       number-font findfont [21 0 0 18 0 0] makefont setfont
  76.       0.324 inch -0.375 inch moveto
  77.       90 rotate
  78.       dup stringwidth pop /sw exch def
  79.       sw 0.54 inch gt { 0.54 inch sw div 1 scale } if
  80.       centershow
  81.     grestore
  82. } bdef
  83.  
  84. /draw-side-label {
  85.   gsave
  86.     0 0 moveto
  87.     translate
  88.     internal-draw-side-label
  89.     /names exch def
  90.     /height 0.5 inch names length div def
  91.     side-font findfont [height 0.9 mul 0 0 height 0 0] makefont setfont
  92.     FG setgray
  93.     1.05 inch -0.1 inch height sub moveto
  94.     names {
  95.       dup type /arraytype eq
  96.       { dup 0 get gsave show grestore
  97.     1 get gsave 4.1 inch 0 rmoveto rightshow grestore }
  98.       { gsave show grestore }
  99.       ifelse
  100.       0 height neg rmoveto
  101.     } forall
  102.   grestore
  103. } bdef
  104.  
  105.  
  106. /internal-draw-top-label {
  107.   gsave
  108.      1 setlinejoin
  109.      MG setgray
  110.      0 0 3.1 inch 1.75 inch box fill
  111.      0 setgray 
  112.      0 0 3.1 inch 1.75 inch box stroke
  113.      BG setgray 
  114.      0.1 inch  -0.5 inch  2.9 inch  1.15 inch  box fill
  115.      0.1 inch  -0.1 inch  2.9 inch  0.3 inch   box fill
  116.      FG setgray
  117.      0.1 inch  -0.5 inch  2.9 inch  1.15 inch  box stroke
  118.      0.1 inch  -0.1 inch  2.9 inch  0.3 inch   box stroke
  119.      
  120.      header-font findfont [12 0 0 15 0 0] makefont setfont
  121.      0.2 inch -0.3 inch moveto   (Tape )show show
  122.      header-font findfont [8 0 0 15 0 0] makefont setfont
  123.      2.9 inch -0.3 inch moveto   ID rightshow
  124.   grestore
  125. } bdef
  126.  
  127. /draw-top-label {
  128.   gsave
  129.     0 0 moveto
  130.     translate
  131.     internal-draw-top-label
  132.     /names exch def
  133.     top-font findfont [9 0 0 10 0 0] makefont setfont
  134.     FG setgray
  135.     0.2 inch -0.5 inch 9 dup add sub moveto
  136.     names {
  137.       dup type /arraytype eq
  138.       { dup 0 get gsave show grestore
  139.     1 get gsave 2.7 inch 0 rmoveto rightshow grestore }
  140.       { gsave show grestore }
  141.       ifelse
  142.       0 -9 rmoveto
  143.     } forall
  144.   grestore
  145. } bdef
  146.  
  147. /flag false def
  148. /count 0 def
  149.  
  150. /showpage {
  151.   initgraphics
  152.   0 setgray
  153.   8 inch 0.25 inch moveto 90 rotate
  154.   /Helvetica findfont 6 scalefont setfont
  155.   (video-tape.ps, version 2.0 (c) 1991 Jamie Zawinski <jwz@lucid.com>) show
  156.   systemdict begin showpage end
  157. } bdef
  158.  
  159. /draw-label {
  160.   /names exch def
  161.   /number exch def
  162.   names number 0.5 inch
  163.     flag { 3.58 inch } { 1.02 inch } ifelse
  164.   names number
  165.     flag { 3.63 inch } { 0.5 inch } ifelse
  166.   2.8 inch
  167.   gsave draw-top-label grestore
  168.   gsave draw-side-label grestore
  169.   flag {
  170.     0 3.35 inch translate
  171.     /count count 1 add def
  172.     count 3 eq { showpage /count 0 def } if
  173.   } if
  174.   /flag flag not def
  175. } bdef
  176.  
  177. %%EndProlog
  178.  
  179. %% Examples.
  180.  
  181.  
  182. (006)    [[(DEFCON-4)                (0)]
  183.      [(Videodrome)                ()]
  184.      [(An American Werewolf in London)    ()]]
  185. draw-label
  186.  
  187. (008)    [(Birdy)
  188.      (Rosemary's Baby)
  189.      (Repo Man)
  190.      (How the Grinch Stole Christmas)]
  191. draw-label
  192.  
  193. (023)    [[(The Art of Noise Live)        (0)]
  194.      [(Duran Duran)                (1117)]
  195.      [(Depeche Mode Live in Hamburg)    (1880)]
  196.      [(The The: Infected)            (2548)]
  197.      [(Sugarcubes Live)            (3487)]
  198.      [(Siouxsie and the Banshees: Once Upon a Time)    ()]]
  199. draw-label
  200.  
  201. (028)    [[(The Thing)                (0)]
  202.      [(Attack of the Killer Tomatoes)    (1844)]
  203.      [(Time Bandits)            (2840)]
  204.      [(Max Headroom)            (3922)]
  205.      [()                    (4410)]]
  206. draw-label
  207.  
  208. (057)    [[(Someone to Watch Over Me)        (0:00)]
  209.      [(The Abyss)                (1:46)]
  210.      [(Internal Affairs)            (4:11)]
  211.      [()                    (6:04)]]
  212. draw-label
  213.  
  214. (002)    [(Logan's Run)
  215.      (The Terminator)
  216.      (The Hunger)
  217.      (New Twilight Zone: "Aqua Vita")]
  218. draw-label
  219.  
  220. (051)    [[(The Blob)                (0)]
  221.      [(Straight to Hell)            (1653)]
  222.      [(Legend)                (2679)]
  223.      [(The Company of Wolves)        (4:29)]]
  224. draw-label
  225.  
  226. (053)    [[(Tapeheads)                (0)]
  227.      [(Hellbound: Hellraiser 2)        (1:33)]
  228.      [(The Kiss)                (3:11)]
  229.      (Penn and Teller's Cruel Tricks)
  230.      [(  for Dear Friends)            (4:56)]]
  231. draw-label
  232.  
  233.  
  234. %%Trailer
  235. %
  236. % This line must always be at the end of the file to ensure 
  237. % that the last page is forced out even if it's not full.
  238. %
  239. count 0 eq not { showpage } if
  240.