]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
Merge branch 'master' of ssh://jneem@git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / lily / lookup.cc
index 8a81937352cf543edcca502706b422341a43ae8e..0050002223848461c7adfed53f0f1ac5bf07cc6a 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   Jan Nieuwenhuizen <janneke@gnu.org>
 */
@@ -106,7 +106,7 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash_period, Real dash_fraction)
                        ly_quote_scm (l),
                        SCM_UNDEFINED));
 
-  Box box (Interval (0, 0), Interval (0, 0));
+  Box box (b.extent (X_AXIS), b.extent (Y_AXIS));
   return Stencil (box, at);
 }
 
@@ -256,8 +256,8 @@ Lookup::round_filled_polygon (vector<Offset> const &points,
   /* remove consecutive duplicate points */
   for (vsize i = 0; i < points.size (); i++)
     {
-      int next_i = (i + 1) % points.size ();
-      Real d = (points[i] - points[next_i]).length ();
+      int next = (i + 1) % points.size ();
+      Real d = (points[i] - points[next]).length ();
       if (d < epsilon)
        programming_error ("Polygon should not have duplicate points");
     }
@@ -714,17 +714,29 @@ Lookup::triangle (Interval iv, Real thick, Real protude)
   b[X_AXIS] = Interval (0, iv.length ());
   b[Y_AXIS] = Interval (min (0., protude), max (0.0, protude));
 
-  Offset z1 (iv[LEFT], 0);
-  Offset z2 (iv[RIGHT], 0);
-  Offset z3 ((z1 + z2)[X_AXIS] / 2, protude);
+  vector<Offset> points;
+  points.push_back (Offset (iv[LEFT], 0));
+  points.push_back (Offset (iv[RIGHT], 0));
+  points.push_back (Offset (iv.center (), protude));
 
-  /*
-    TODO: move Triangle to Line_interface ?
-  */
-  Stencil tri = Line_interface::make_line (thick, z1, z2);
-  tri.add_stencil (Line_interface::make_line (thick, z2, z3));
-  tri.add_stencil (Line_interface::make_line (thick, z3, z1));
+  return points_to_line_stencil (thick, points);
 
-  return tri;
 }
 
+
+
+Stencil
+Lookup::points_to_line_stencil (Real thick, vector<Offset> const &points)
+{
+  Stencil ret;
+  for (vsize i = 1; i < points.size (); i++)
+    {
+      if (points[i-1].is_sane () && points[i].is_sane ())
+       {
+         Stencil line
+           = Line_interface::make_line (thick, points[i-1], points[i]);
+         ret.add_stencil (line);
+       }
+    }
+  return ret;
+}