lilypond-0.1.45
[lilypond.git] / tex / lily-ps-defs.tex
blobcab0aaa82c6a3e0a4afd5bf501e9899faf435a8d
2 % WARNING: don't leave blank lines in the PS-code; they are
3 % transformed into \par
7 % Should put in a lily-ps.ps header?
12 % header info (macros/defs, etc) should go into a \special{! ... },
13 % note the ! sign. See dvips.info for details.
16 % Use of
17 % /foo { operatorname } bind def
19 % ``compiles'' operatorname binding in the body of foo, making
20 % the code faster, and more reliable (less flexible)
23 % transplant a TeX dimension into the PS output.
24 \def\PSsetTeXdimen#1{\expandafter\special{! /#1 (\the\csname #1\endcsname) deftexdimen}}
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}
34 % width, slope, height
36 \special{! % round cappings
37 1 setlinecap
38 /draw_beam
40 2 div /beam_thick exch def
41 /beam_slope exch def
42 /beam_wd exch def
43 beam_slope beam_wd mul /beam_ht exch def
44 0 beam_thick neg moveto
45 beam_wd beam_ht rlineto
46 0 beam_thick 2 mul rlineto
47 0 beam_thick lineto
48 closepath fill
49 } bind def
50 % PS helper: convert (0.2pt) to the token 0.2
51 /settexdimen { /thestring exch def
52 thestring 0 thestring length 2 sub
53 getinterval
54 token
55 pop exch pop }
56 def
58 /deftexdimen {
59 settexdimen
60 def
61 } def
65 \PSsetTeXdimen{staffrulethickness}
66 \PSsetTeXdimen{staffheight}
67 \special{! %
68 /draw_decresc
70 staffrulethickness setlinewidth
71 /cresc_cont exch def
72 /cresc_ht exch def
73 /cresc_wd exch def
75 cresc_wd cresc_cont moveto
76 0 cresc_ht lineto
77 stroke
78 cresc_wd cresc_cont neg moveto
79 0 cresc_ht neg lineto
80 stroke
82 bind def
83 /draw_cresc
85 staffrulethickness setlinewidth
86 /cresc_cont exch def
87 /cresc_ht exch def
88 /cresc_wd exch def
90 0 cresc_cont moveto
91 cresc_wd cresc_ht lineto
92 stroke
93 0 cresc_cont neg moveto
94 cresc_wd cresc_ht neg lineto
95 stroke
97 bind def
98 /lily_distance {
99 1 copy mul exch 1 copy mul add sqrt
100 } bind def
101 /draw_plet
103 staffrulethickness setlinewidth
104 /dir exch def
105 /plet_dy exch def
106 /plet_dx exch def
107 staffheight 2 div /plet_gapx exch def
108 plet_dy plet_dx div plet_gapx mul /plet_gapy exch def
109 staffheight 4 div dir mul /plet_h exch def
111 0 0 moveto
112 0 plet_h lineto
113 plet_dx plet_gapx sub 2 div
114 plet_dy plet_gapy sub 2 div plet_h add lineto
115 plet_dx plet_gapx add 2 div
116 plet_dy plet_gapy add 2 div plet_h add moveto
117 plet_dx plet_dy plet_h add lineto
118 plet_dx plet_dy lineto
119 stroke
121 bind def
122 staffheight 2 div /slurhtlimit exch def
123 /slurratio 0.3333 def
125 % (b*ratio)/(1 + b / htlimit)
126 /getslurcontrol
128 slurhtlimit add /slurheight exch def
129 slurheight 90 div /slur_alpha exch def
130 slurratio 60 div slur_alpha div /slur_beta exch def
131 slur_beta mul 1 atan slur_alpha mul
132 } bind def
133 staffrulethickness 1.5 mul /slur_thick exch def
134 /draw_slur
136 staffrulethickness setlinewidth
137 0 0 moveto
138 /slur_dir exch def
139 /slur_height exch def
140 /slur_dy exch def
141 /slur_dx exch def
142 slur_dy slur_dx lily_distance /slur_b exch def
143 slur_b slur_height getslurcontrol
144 slur_dir mul /slur_ht exch def
145 slur_b slur_height getslurcontrol /slur_indent exch def
147 slur_dy slur_dx atan rotate
148 slur_indent slur_ht
149 slur_b slur_indent sub slur_ht
150 slur_b 0
151 rcurveto
153 slur_indent neg slur_ht slur_dir slur_thick mul sub
154 slur_indent slur_b sub slur_ht slur_dir slur_thick mul sub
155 slur_b neg 0
156 rcurveto
158 gsave
159 fill
160 grestore
161 stroke
162 } bind def}}
167 \def\turnOnExperimentalFeatures{
168 % draw a slur in embedded postscript
169 \special{ps: