]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
lilypond-manuals.css: edit color scheme and some spacing
[lilypond.git] / lily / lookup.cc
index 5678c35b57708f70dd486d05b8c3fb428ad9901a..d7b6b8d26e9bc81c5eada2ab7911128c1de26a2d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <cmath>
 #include <cctype>
+using namespace std;
 
 #include "line-interface.hh"
 #include "warn.hh"
@@ -33,8 +34,6 @@
 #include "main.hh"
 #include "lily-guile.hh"
 
-using std::vector;
-
 Stencil
 Lookup::beam (Real slope, Real width, Real thick, Real blot)
 {
@@ -76,11 +75,10 @@ Lookup::beam (Real slope, Real width, Real thick, Real blot)
                      scm_cons (scm_from_double (p[Y_AXIS]),
                                points));
 
-  SCM expr = scm_list_n (ly_symbol2scm ("polygon"),
+  SCM expr = scm_list_4 (ly_symbol2scm ("polygon"),
                          ly_quote_scm (points),
                          scm_from_double (blot),
-                         SCM_BOOL_T,
-                         SCM_UNDEFINED);
+                         SCM_BOOL_T);
 
   return Stencil (b, expr);
 }
@@ -169,9 +167,9 @@ Stencil
 Lookup::round_filled_box (Box b, Real blotdiameter)
 {
   Real width = b.x ().delta ();
-  blotdiameter = std::min (blotdiameter, width);
+  blotdiameter = min (blotdiameter, width);
   Real height = b.y ().delta ();
-  blotdiameter = std::min (blotdiameter, height);
+  blotdiameter = min (blotdiameter, height);
 
   if (blotdiameter < 0.0)
     {
@@ -248,9 +246,9 @@ Lookup::round_filled_polygon (vector<Offset> const &points,
      applies to the given polygon.  However, this is quite complicated
      to check. */
 
+#ifdef DEBUG
   const Real epsilon = 0.01;
 
-#ifdef DEBUG
   /* remove consecutive duplicate points */
   for (vsize i = 0; i < points.size (); i++)
     {
@@ -374,11 +372,10 @@ Lookup::round_filled_polygon (vector<Offset> const &points,
     }
   shrunk_box.widen (0.5*blotdiameter, 0.5*blotdiameter);
   box.unite (shrunk_box);
-  SCM polygon_scm = scm_list_n (ly_symbol2scm ("polygon"),
+  SCM polygon_scm = scm_list_4 (ly_symbol2scm ("polygon"),
                                 ly_quote_scm (shrunk_points_scm),
                                 scm_from_double (blotdiameter),
-                                SCM_BOOL_T,
-                                SCM_UNDEFINED);
+                                SCM_BOOL_T);
 
   Stencil polygon = Stencil (box, polygon_scm);
   return polygon;
@@ -420,9 +417,9 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick,
       calculate the offset for the two beziers that make the sandwich
       for the slur
   */
-  Real alpha = (curve.control_[3] - curve.control_[0]).arg ();
+  Offset dir = (curve.control_[3] - curve.control_[0]).direction ();
   Bezier back = curve;
-  Offset perp = curvethick * complex_exp (Offset (0, alpha + M_PI / 2)) * 0.5;
+  Offset perp = 0.5 * curvethick * Offset (-dir[Y_AXIS], dir[X_AXIS]);
   back.control_[1] += perp;
   back.control_[2] += perp;
 
@@ -550,7 +547,7 @@ Stencil
 Lookup::repeat_slash (Real w, Real s, Real t)
 {
 
-  Real x_width = sqrt ((t * t) + ((t / s) * (t / s)));
+  Real x_width = hypot (t, t/s);
   Real height = w * s;
 
   SCM controls = scm_list_n (ly_symbol2scm ("moveto"),
@@ -576,8 +573,8 @@ Lookup::repeat_slash (Real w, Real s, Real t)
                                SCM_BOOL_T,
                                SCM_UNDEFINED);
 
-  Box b (Interval (0, w + sqrt (sqr (t / s) + sqr (t))),
-         Interval (0, w * s));
+  Box b (Interval (0, w + x_width),
+         Interval (0, height));
 
   return Stencil (b, slashnodot); //  http://slashnodot.org
 }
@@ -586,7 +583,7 @@ Stencil
 Lookup::bracket (Axis a, Interval iv, Real thick, Real protrude, Real blot)
 {
   Box b;
-  Axis other = Axis ((a + 1) % 2);
+  Axis other = other_axis (a);
   b[a] = iv;
   b[other] = Interval (-1, 1) * thick * 0.5;
 
@@ -608,7 +605,7 @@ Lookup::triangle (Interval iv, Real thick, Real protrude)
 {
   Box b;
   b[X_AXIS] = Interval (0, iv.length ());
-  b[Y_AXIS] = Interval (std::min (0., protrude), std::max (0.0, protrude));
+  b[Y_AXIS] = Interval (min (0., protrude), max (0.0, protrude));
 
   vector<Offset> points;
   points.push_back (Offset (iv[LEFT], 0));