]> git.donarmstrong.com Git - lilypond.git/blob - mf/feta-macros.mf
release: 0.1.20
[lilypond.git] / mf / feta-macros.mf
1 %
2 % debugging
3 %
4 def test_grid =
5 if test>1:
6         proofrulethickness 1pt#;
7         makegrid(0pt,0pt for i:=-5pt step 1pt until 5pt: ,i endfor)
8                 (0pt,0pt for i:=-5pt step 1pt until 5pt: ,i endfor);
9         proofrulethickness .1pt#;
10         makegrid(0pt,0pt for i:=-4.8pt step .2pt until 4.8pt: ,i endfor)
11                 (0pt,0pt for i:=-4.8pt step .2pt until 4.8pt: ,i endfor);
12 fi
13         enddef;
14
15 def treq =
16         tracingequations := tracingonline := 1;
17 enddef;
18
19
20 %
21 % Transforms
22 %
23
24 def scaledabout(expr point, scale) =
25         shifted -point scaled scale shifted point
26 enddef;
27
28 %
29 % Urgh! Want to do parametric types
30 %
31
32 def del_picture_stack=
33         save save_picture_stack, picture_stack_idx;
34 enddef;
35
36 % better versions of Taupin/Egler savepic cmds
37 %
38 %
39 def make_picture_stack = 
40         % override previous stack.
41         del_picture_stack;
42         picture save_picture_stack[];
43         numeric picture_stack_idx;
44         picture_stack_idx := 0;
45         def push_picture(expr p) = 
46                 save_picture_stack[picture_stack_idx] := p ;
47                 picture_stack_idx := picture_stack_idx + 1;
48         enddef;
49         def pop_picture =  save_picture_stack[decr picture_stack_idx] enddef;
50         def top_picture = save_picture_stack[picture_stack_idx] enddef;
51 enddef;
52
53
54 % save/restore pens
55 % why can't I delete individual pens?
56 def make_pen_stack =
57         del_pen_stack;
58         pen save_pen_stack[];
59         numeric pen_stack_idx;
60         pen_stack_idx := 0;
61         def push_pen(expr p) = 
62                 save_pen_stack[pen_stack_idx] := p ;
63                 pen_stack_idx := pen_stack_idx +1;
64         enddef;
65         def pop_pen =  save_pen_stack[decr pen_stack_idx] enddef;
66         def top_pen = save_pen_stack[pen_stack_idx] enddef;
67 enddef;
68 def del_pen_stack=
69         save save_pen_stack, pen_stack_idx;
70 enddef;
71
72 %
73 % drawing
74 %
75
76 % a: x diameter
77 % b: y diameter
78 % err_x: drift of y axis at top
79 % err_y: drift of x axis at right
80 def distorted_ellipse(expr a,b,err_y,err_x,super) =
81         superellipse((a,err_x),(-err_y,b),(-a,-err_x),(err_y,-b),super);
82         enddef;
83
84 def draw_brush(expr a,w,b,v) =
85         save x,y;
86         z1=a; z2=b;
87         penpos3(w,angle(z2-z1)+90);
88         penpos4(w,angle(z2-z1));
89         penpos5(v,angle(z1-z2)+90);
90         penpos6(v,angle(z1-z2));
91         z3 = z4 = z1;
92         z5 = z6 = z2;
93
94         fill z3r{z3r-z5l}..z4l..{z5r-z3l}z3l..z5r{z5r-z3l}..z6l..{z3r-z5l}z5l..cycle;
95 enddef;
96
97 def brush(expr a,w,b,v) =
98         begingroup;
99         draw_brush(a,w,b,v);    
100         penlabels(3,4,5,6);
101         endgroup;
102 enddef;
103
104 def draw_rounded_path(expr p, thick) =
105         push_pen(currentpen);
106         fill p;
107         pickup pencircle scaled thick;
108         draw p;
109         currentpen := pop_pen;
110 enddef;
111
112 %
113 %
114 %
115 def balled_crook(expr a, w, balldiam, stem) =
116 begingroup;
117         save x,y;
118         penpos1(balldiam/2,-90);
119         penpos2(balldiam/2,0);
120         penpos3(balldiam/2,90);
121         penpos4(balldiam/2,180);
122         x4r=xpart a-w; y3r=ypart a+balldiam/4;
123         x1l=x2l=x3l=x4l;
124         y1l=y2l=y3l=y4l;
125         penpos5(stem,250);
126         x5=x4r+9/8balldiam; y5r=y1r;
127         penpos6(stem,260);
128         x6l=xpart a; y6l=ypart a;
129         penstroke z1e..z2e..z3e..z4e..z1e..z5e{right}..z6e;
130         penlabels(1,2,3,4,5,6);
131 endgroup;
132 enddef;
133
134 def y_mirror_char =
135         currentpicture := currentpicture yscaled -1;
136         set_char_box(charbp, charwd, charht, chardp);
137 enddef;
138
139
140 def xy_mirror_char =
141         currentpicture := currentpicture scaled -1;
142         set_char_box(charwd, charbp, charht, chardp);
143 enddef;