% 
% feta-sleur.mf --  implement runtime MF slurs
% 
% source file of LilyPond's pretty-but-neat music font
% 
% (c)  1997--2003 Jan Nieuwenhuizen <janneke@gnu.org>
% & Han-Wen Nienhuys <hanwen@cs.uu.nl>
% 
% see Documentation/fonts.tex

% mode_setup;

%% staffsize#=16pt#;
% staff_space#:=staffsize#/4;
% stafflinethickness#:=0.1staff_space#;

pi:=3.14159;

def atan(expr x) = 
	(angle(1,x)*pi/180)
	enddef;


sleur_pen#:=stafflinethickness#;
slurheightlimit#:=staffsize#/2;
slurthick#:=1.8stafflinethickness#;

define_pixels(staffsize,staff_space,stafflinethickness);
define_pixels(sleur_pen,slurheightlimit,slurthick);

sluralpha:=2slurheightlimit#/pi;
slurratio:=1/3;
slurbeta:=pi*slurratio/2slurheightlimit#;

def draw_slur(expr dxs,dys,hs,d) =
	save x, y;
	save b, dx, dy, h, indent;
	dx#:=dxs*1pt#;
	dy#:=dys*1pt#;
	h#:=hs*1pt#;
	define_pixels(dx,dy);
	b#:=length(dx#,dy#);
	indent#:=sluralpha*atan(slurbeta*b#);
	define_pixels(b,h,indent);
	height:=(indent+h)*d;
	z1=(0,0);
	z2=(b,0);
	z3=(indent,height);
	z4=(b-indent,height);
	z5=z4-(0,d*slurthick);
	z6=z3-(0,d*slurthick);
	path boogje;
	boogje=z1..controls z3 and z4..z2..controls z5 and z6..cycle;
	boogje:=boogje rotated angle(dxs,dys);
	pickup pencircle scaled sleur_pen;
	filldraw boogje;
enddef;


