]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
* mf/GNUmakefile: always trace pfa fonts.
[lilypond.git] / lily / lookup.cc
index 1783f95467c40024f04cc64c5b79405b6978da3d..9781002205780066c6ba28ff4522252f95791172 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 
   Jan Nieuwenhuizen <janneke@gnu.org>
 
@@ -81,19 +81,19 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 }
 
 Molecule
-Lookup::line (Real th, Offset f, Offset t)
+Lookup::line (Real th, Offset from, Offset to)
 {
-  SCM at = (scm_list_n (ly_symbol2scm ("draw-line"),
+  SCM at = scm_list_n (ly_symbol2scm ("draw-line"),
                        gh_double2scm (th), 
-                       gh_double2scm (f[X_AXIS]),
-                       gh_double2scm (f[Y_AXIS]),
-                       gh_double2scm (t[X_AXIS]),
-                       gh_double2scm (t[Y_AXIS]),
-                       SCM_UNDEFINED));
+                       gh_double2scm (from[X_AXIS]),
+                       gh_double2scm (from[Y_AXIS]),
+                       gh_double2scm (to[X_AXIS]),
+                       gh_double2scm (to[Y_AXIS]),
+                       SCM_UNDEFINED);
 
   Box box;
-  box.add_point (f);
-  box.add_point (t);
+  box.add_point (from);
+  box.add_point (to);
 
   box[X_AXIS].widen (th/2);
   box[Y_AXIS].widen (th/2);  
@@ -101,11 +101,56 @@ Lookup::line (Real th, Offset f, Offset t)
   return Molecule (box, at);
 }
 
+Molecule
+Lookup::dashed_line (Real thick, Offset from, Offset to,
+                    Real dash_period, Real dash_fraction)
+{
+  dash_fraction = (dash_fraction >? 0) <? 1.0;
+  Real on = dash_fraction * dash_period + thick; 
+  Real off = dash_period - on;
+  
+  SCM at = scm_list_n (ly_symbol2scm ("dashed-line"),
+                       gh_double2scm (thick), 
+                       gh_double2scm (on),
+                       gh_double2scm (off),
+                       gh_double2scm (to[X_AXIS] - from[X_AXIS]),
+                       gh_double2scm (to[Y_AXIS] - from[Y_AXIS]),
+                       SCM_UNDEFINED);
+  
+  Box box;
+  box.add_point (Offset (0,0));
+  box.add_point (to - from);
+
+  box[X_AXIS].widen (thick/2);
+  box[Y_AXIS].widen (thick/2);  
+
+  Molecule m = Molecule (box, at);
+  m.translate (from);
+  return m;
+}
+
+Molecule
+Lookup::horizontal_line (Interval w, Real th)
+{
+  SCM at = scm_list_n (ly_symbol2scm ("horizontal-line"),
+                      gh_double2scm (w[LEFT]), 
+                      gh_double2scm (w[RIGHT]),
+                      gh_double2scm (th),
+                      SCM_UNDEFINED);
+
+
+  Box box ;
+  box[X_AXIS] = w;
+  box[Y_AXIS] = Interval (-th/2,th/2);
+
+  return Molecule (box, at);
+}
+
 
 Molecule
 Lookup::blank (Box b) 
 {
-  return Molecule (b, SCM_EOL);
+  return Molecule (b, scm_makfrom0str (""));
 }
 
 Molecule
@@ -149,7 +194,7 @@ Lookup::filledbox (Box b)
  *       Box extent(X_AXIS)
  */
 Molecule
-Lookup::roundfilledbox (Box b, Real blotdiameter)
+Lookup::round_filled_box (Box b, Real blotdiameter)
 {
   if (b.x ().length () < blotdiameter)
     {
@@ -162,7 +207,7 @@ Lookup::roundfilledbox (Box b, Real blotdiameter)
       blotdiameter = b.y ().length ();
     }
 
-  SCM at = (scm_list_n (ly_symbol2scm ("roundfilledbox"),
+  SCM at = (scm_list_n (ly_symbol2scm ("round-filled-box"),
                        gh_double2scm (-b[X_AXIS][LEFT]),
                        gh_double2scm (b[X_AXIS][RIGHT]),
                        gh_double2scm (-b[Y_AXIS][DOWN]),
@@ -173,6 +218,8 @@ Lookup::roundfilledbox (Box b, Real blotdiameter)
   return Molecule (b,at);
 }
 
+         
+
 /*
  * Create Molecule that represents a filled polygon with round edges.
  *
@@ -297,7 +344,7 @@ Lookup::round_filled_polygon (Array<Offset> points, Real blotdiameter)
       box.add_point (points[i]);
     }
   SCM polygon_scm = scm_list_n (ly_symbol2scm ("polygon"),
-                               ly_quote_scm (ly_quote_scm (shrinked_points_scm)),
+                               ly_quote_scm (shrinked_points_scm),
                                gh_double2scm (blotdiameter),
                                SCM_UNDEFINED);
 
@@ -363,7 +410,7 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
     }
   
   
-  SCM at = (scm_list_n (ly_symbol2scm ("bezier-bow"),
+  SCM at = (scm_list_n (ly_symbol2scm ("bezier-sandwich"),
                     ly_quote_scm (list),
                     gh_double2scm (linethick),
                     SCM_UNDEFINED));
@@ -723,8 +770,8 @@ LY_DEFINE(ly_bracket ,"ly:bracket",
          "given by @var{iv}. The wings protude by an amount of @var{p}, which "
          "may be negative. The thickness is given by @var{t}.")
 {
-  SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
-  SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(is_axis (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
+  SCM_ASSERT_TYPE(is_number_pair (iv), iv, SCM_ARG2, __FUNCTION__, "number pair") ;
   SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG3, __FUNCTION__, "number") ;
   SCM_ASSERT_TYPE(gh_number_p (p), a, SCM_ARG4, __FUNCTION__, "number") ;
 
@@ -733,4 +780,19 @@ LY_DEFINE(ly_bracket ,"ly:bracket",
                          gh_scm2double (t),
                          gh_scm2double (p)).smobbed_copy ();
 }
-  
+
+
+
+LY_DEFINE(ly_filled_box ,"ly:round-filled-box",
+         3, 0, 0,
+         (SCM xext, SCM yext, SCM blot),
+         "Make a filled-box of dimensions @var{xext}, @var{yext} and roundness @var{blot}.")
+{
+  SCM_ASSERT_TYPE(is_number_pair (xext), xext, SCM_ARG1, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(is_number_pair (yext), yext, SCM_ARG2, __FUNCTION__, "number pair") ;
+  SCM_ASSERT_TYPE(gh_number_p (blot), blot, SCM_ARG3, __FUNCTION__, "number") ;
+
+  return Lookup::round_filled_box (Box (ly_scm2interval (xext), ly_scm2interval (yext)),
+                                  gh_scm2double (blot)).smobbed_copy ();
+}
+