]> git.donarmstrong.com Git - lilypond.git/blob - tex/lily-ps-defs.tex
release: 0.1.58
[lilypond.git] / tex / lily-ps-defs.tex
1 %
2 % WARNING: don't leave blank lines in the PS-code; they are
3 % transformed into \par 
4 %
5
6 %
7 % Should put in a lily-ps.ps header?
8 %
9 %
10
11 %
12 % header info (macros/defs, etc) should go into a \special{! ... }, 
13 % note the ! sign.  See dvips.info for details.
14 %
15
16 % Use of 
17 % /foo { operatorname } bind def
18 %
19 % ``compiles'' operatorname binding in the body of foo, making
20 % the code faster, and more reliable (less flexible)
21
22
23 % transplant a TeX dimension into the PS output.
24 \def\PSsetTeXdimen#1{\expandafter\special{! /#1 (\the\csname #1\endcsname) deftexdimen}}
25
26 \def\turnOnPostScript{%
27 \def\embeddedps##1{%
28         % This sets CTM so that you get to the currentpoint
29         % by executing a 0 0 moveto
30         \special{ps: @beginspecial @setspecial ##1 @endspecial}       
31 }
32 %
33 % width, slope, height 
34 %
35 \special{! % round cappings
36 1 setlinecap
37 /draw_beam
38 {
39         2 div /beam_thick exch def
40         /beam_slope exch def
41         /beam_wd exch def
42         beam_slope beam_wd mul /beam_ht exch def
43         0 beam_thick neg moveto 
44         beam_wd beam_ht rlineto 
45         0 beam_thick 2 mul rlineto
46         0 beam_thick lineto
47         closepath fill
48 } bind def
49 % PS helper: convert (0.2pt) to the token 0.2
50 /settexdimen {  /thestring exch def
51         thestring 0 thestring length 2 sub
52         getinterval
53         token
54         pop exch pop } 
55 def
56 %
57 /deftexdimen {
58         settexdimen
59         def     
60 } def
61 }
62 %
63 \PSsetTeXdimen{staffrulethickness}
64 \PSsetTeXdimen{staffheight}
65 \special{! %
66 /draw_decresc
67         {
68                 staffrulethickness setlinewidth
69                 /cresc_cont exch def
70                 /cresc_ht exch def
71                 /cresc_wd exch def
72 %
73                 cresc_wd cresc_cont moveto
74                 0 cresc_ht lineto
75                 stroke
76                 cresc_wd cresc_cont neg moveto
77                 0 cresc_ht neg lineto
78                 stroke
79         }
80         bind def
81         /draw_cresc
82         {
83                 staffrulethickness setlinewidth
84                 /cresc_cont exch def
85                 /cresc_ht exch def
86                 /cresc_wd exch def
87 %
88                 0 cresc_cont moveto
89                 cresc_wd cresc_ht lineto
90                 stroke
91                 0 cresc_cont neg moveto
92                 cresc_wd cresc_ht neg lineto
93                 stroke
94         }
95         bind def
96  /lily_distance {
97         1 copy mul exch 1 copy mul add sqrt
98  } bind def
99  /draw_plet
100         {
101                 staffrulethickness setlinewidth
102                 /dir exch def
103                 /plet_dy exch def
104                 /plet_dx exch def
105                 staffheight 2 div /plet_gapx exch def
106                 plet_dy plet_dx div plet_gapx mul /plet_gapy exch def
107                 staffheight 4 div dir mul /plet_h exch def
108 %
109                 0 0 moveto
110                 0 plet_h lineto 
111                 plet_dx plet_gapx sub 2 div 
112                         plet_dy plet_gapy sub 2 div plet_h add lineto
113                 plet_dx plet_gapx add 2 div 
114                         plet_dy plet_gapy add 2 div plet_h add moveto
115                 plet_dx plet_dy plet_h add lineto
116                 plet_dx plet_dy lineto
117                 stroke
118         }
119         bind def
120  staffheight 2 div /slurhtlimit exch def
121 /draw_slur
122 {
123         staffrulethickness setlinewidth
124         0 0 moveto
125         rcurveto
126         rcurveto
127         gsave
128         fill
129         grestore
130         stroke
131         } bind def
132 }}
133
134 \def\turnOnExperimentalFeatures{%
135 % draw a slur in embedded postscript
136 \special{ps:
137 }}
138