]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lookup.cc
''
[lilypond.git] / lily / lookup.cc
index 34158202053f5004d607035aea16f13304f6928f..e8f5bb03fc9d09b50a2ce6d1e657e41b29ca58db 100644 (file)
@@ -45,7 +45,6 @@ Lookup::beam (Real slope, Real width, Real thick)
   return Molecule (b, at);
 }
 
-
 Molecule
 Lookup::dashed_slur (Bezier b, Real thick, Real dash)
 {
@@ -72,7 +71,6 @@ Lookup::blank (Box b)
   return Molecule (b, SCM_EOL);
 }
 
-
 Molecule
 Lookup::filledbox (Box b) 
 {
@@ -86,6 +84,57 @@ Lookup::filledbox (Box b)
   return Molecule (b,at);
 }
 
+/*
+ * round filled box:
+ *
+ *   __________________________________
+ *  /     \  ^           /     \      ^
+ * |         |blot              |     |
+ * |       | |dia       |       |     |
+ * |         |meter             |     |
+ * |\ _ _ /  v           \ _ _ /|     |
+ * |                            |     |
+ * |                            |     | Box
+ * |                    <------>|     | extent
+ * |                      blot  |     | (Y_AXIS)
+ * |                    diameter|     |
+ * |                            |     |
+ * |  _ _                  _ _  |     |
+ * |/     \              /     \|     |
+ * |                            |     |
+ * |       |            |       |     |
+ * |                            |     |
+ * x\_____/______________\_____/|_____v
+ * |(0,0)                       |
+ * |                            |
+ * |                            |
+ * |<-------------------------->|
+ *       Box extent(X_AXIS)
+ */
+Molecule
+Lookup::roundfilledbox (Box b, Real blotdiameter)
+{
+  if (b.x ().length () < blotdiameter)
+    {
+      programming_error (_f ("round filled box horizontal extent smaller than blot; decreasing blot"));
+      blotdiameter = b.x ().length ();
+    }
+  if (b.y ().length () < blotdiameter)
+    {
+      programming_error (_f ("round filled box vertical extent smaller than blot; decreasing blot"));
+      blotdiameter = b.y ().length ();
+    }
+
+  SCM at = (scm_list_n (ly_symbol2scm ("roundfilledbox"),
+                       gh_double2scm (-b[X_AXIS][LEFT]),
+                       gh_double2scm (b[X_AXIS][RIGHT]),
+                       gh_double2scm (-b[Y_AXIS][DOWN]),
+                       gh_double2scm (b[Y_AXIS][UP]),
+                       gh_double2scm (blotdiameter),
+                       SCM_UNDEFINED));
+
+  return Molecule (b,at);
+}
 
 Molecule
 Lookup::frame (Box b, Real thick)
@@ -112,7 +161,6 @@ Lookup::frame (Box b, Real thick)
   
 }
 
-
 /*
   Make a smooth curve along the points 
  */
@@ -160,6 +208,90 @@ Lookup::slur (Bezier curve, Real curvethick, Real linethick)
   return Molecule (b, at);
 }
 
+/*
+ * Bezier Sandwich:
+ *
+ *                               .|
+ *                        .       |
+ *              top .             |
+ *              . curve           |
+ *          .                     |
+ *       .                        |
+ *     .                          |
+ *    |                           |
+ *    |                          .|
+ *    |                     .
+ *    |         bottom .
+ *    |            . curve
+ *    |         .
+ *    |      .
+ *    |   .
+ *    | .
+ *    |.
+ *    |
+ *
+ */
+Molecule
+Lookup::bezier_sandwich (Bezier top_curve, Bezier bottom_curve)
+{
+  /*
+    Need the weird order b.o. the way PS want its arguments  
+   */
+  SCM list = SCM_EOL;
+  list = gh_cons (ly_offset2scm (bottom_curve.control_[3]), list);
+  list = gh_cons (ly_offset2scm (bottom_curve.control_[0]), list);
+  list = gh_cons (ly_offset2scm (bottom_curve.control_[1]), list);
+  list = gh_cons (ly_offset2scm (bottom_curve.control_[2]), list);
+  list = gh_cons (ly_offset2scm (top_curve.control_[0]), list);
+  list = gh_cons (ly_offset2scm (top_curve.control_[3]), list);
+  list = gh_cons (ly_offset2scm (top_curve.control_[2]), list);
+  list = gh_cons (ly_offset2scm (top_curve.control_[1]), list);
+
+  SCM horizontal_bend = scm_list_n (ly_symbol2scm ("bezier-sandwich"),
+                                   ly_quote_scm (list),
+                                   gh_double2scm (0.0),
+                                   SCM_UNDEFINED);
+
+  Interval x_extent = top_curve.extent (X_AXIS);
+  x_extent.unite (bottom_curve.extent (X_AXIS));
+  Interval y_extent = top_curve.extent (Y_AXIS);
+  y_extent.unite (bottom_curve.extent (Y_AXIS));
+  Box b (x_extent, y_extent);
+
+  return Molecule (b, horizontal_bend);
+}
+
+/*
+ * Horizontal Slope:
+ *
+ *            /|   ^
+ *           / |   |
+ *          /  |   | height
+ *         /   |   |
+ *        /    |   v
+ *       |    /
+ *       |   /
+ * (0,0) x  /slope=dy/dx
+ *       | /
+ *       |/
+ *
+ *       <----->
+ *        width
+ */
+Molecule
+Lookup::horizontal_slope (Real width, Real slope, Real height)
+{
+  SCM width_scm = gh_double2scm (width);
+  SCM slope_scm = gh_double2scm (slope);
+  SCM height_scm = gh_double2scm (height);
+  SCM horizontal_slope = scm_list_n (ly_symbol2scm ("beam"),
+                                    width_scm, slope_scm,
+                                    height_scm, SCM_UNDEFINED);
+  Box b (Interval (0, width),
+        Interval (-height/2, height/2 + width*slope));
+  return Molecule (b, horizontal_slope);
+}
+
 /*
   TODO: junk me.
  */
@@ -361,10 +493,6 @@ Lookup::accordion (SCM s, Real staff_space, Font_metric *fm)
   return m;  
 }
 
-/*
-  TODO: should use slope instead?  Angle gives nasty rad <-> degree
-  conversions.
-*/
 Molecule
 Lookup::repeat_slash (Real w, Real s, Real t)
 {
@@ -380,8 +508,6 @@ Lookup::repeat_slash (Real w, Real s, Real t)
   return Molecule (b, slashnodot); //  http://slashnodot.org
 }
 
-
-
 Molecule
 Lookup::bracket (Axis a, Interval iv, Direction d, Real thick, Real protude)
 {
@@ -408,7 +534,7 @@ ly_bracket (SCM a, SCM iv, SCM d, SCM t, SCM p)
 {
   SCM_ASSERT_TYPE(ly_axis_p (a), a, SCM_ARG1, __FUNCTION__, "axis") ;
   SCM_ASSERT_TYPE(ly_number_pair_p (iv), iv, SCM_ARG1, __FUNCTION__, "number pair") ;
-  SCM_ASSERT_TYPE(isdir_b (d), a, SCM_ARG1, __FUNCTION__, "direction") ;
+  SCM_ASSERT_TYPE(ly_dir_p (d), a, SCM_ARG1, __FUNCTION__, "direction") ;
   SCM_ASSERT_TYPE(gh_number_p (t), a, SCM_ARG1, __FUNCTION__, "number") ;
   SCM_ASSERT_TYPE(gh_number_p(p), a, SCM_ARG1, __FUNCTION__, "number") ;