]> git.donarmstrong.com Git - lilypond.git/blob - tex/lily-ps-defs.tex
release: 0.1.41
[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 %
34 % width, slope, height 
35 %
36 \special{! % round cappings
37 1 setlinecap
38 /draw_beam
39 {
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
57 %
58 /deftexdimen {
59         settexdimen
60         def     
61 } def
62 }
63
64
65 \PSsetTeXdimen{staffrulethickness}
66 \PSsetTeXdimen{staffheight}
67 \special{! %
68 /draw_decresc
69         {
70                 staffrulethickness setlinewidth
71                 /cresc_cont exch def
72                 /cresc_ht exch def
73                 /cresc_wd exch def
74 %
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
81         }
82         bind def
83         /draw_cresc
84         {
85                 /cresc_cont exch def
86                 /cresc_ht exch def
87                 /cresc_wd exch def
88 %
89                 0 cresc_cont moveto
90                 cresc_wd cresc_ht lineto
91                 stroke
92                 0 cresc_cont neg moveto
93                 cresc_wd cresc_ht neg lineto
94                 stroke
95         }
96         bind def
97  /lily_distance {
98         1 copy mul exch 1 copy mul add sqrt
99  } bind def
100  staffheight 2 div
101  /slurhtlimit exch def
102  /slurratio 0.3333 def
103  %
104  %  (b*ratio)/(1 + b / htlimit)
105  /getslurcontrol 
106  { 
107         slurhtlimit 90 div /slur_alpha exch def
108         slurratio 60 div slur_alpha div  /slur_beta  exch def
109         slur_beta mul 1 atan slur_alpha mul
110  } bind def
111  staffrulethickness 1.5 mul  /slur_thick exch def
112  /draw_slur
113  {
114         staffrulethickness setlinewidth
115         0 0 moveto
116         /slur_dir exch def
117         /slur_dy exch def
118         /slur_dx exch def
119         slur_dy slur_dx lily_distance /slur_b  exch def
120         slur_b getslurcontrol 
121         slur_dir mul /slur_ht exch def
122         slur_b getslurcontrol /slur_indent exch def       
123 %
124         slur_dy slur_dx atan rotate
125         slur_indent slur_ht
126         slur_b slur_indent sub slur_ht
127         slur_b 0
128         rcurveto        
129  %
130         slur_indent neg slur_ht slur_dir slur_thick mul  sub
131         slur_indent slur_b sub slur_ht slur_dir slur_thick mul  sub
132         slur_b neg  0
133         rcurveto
134  %
135         gsave
136                 fill
137         grestore
138         stroke
139  } bind def}}
140
141
142
143
144 \def\turnOnExperimentalFeatures{
145 % draw a slur in embedded postscript
146 \special{ps:
147 }}