]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tex-beam.cc
release: 0.1.39
[lilypond.git] / lily / tex-beam.cc
index e26b1c481de692263862a05523698e1e52b4514f..d756461a6ff784f8e979605f3fd3de83fe9d4316 100644 (file)
@@ -19,6 +19,7 @@
 #include "debug.hh"
 #include "lookup.hh"
 #include "misc.hh"
+#include "main.hh"
 
 Atom
 Lookup::beam_element (int sidx, int widx, Real slope) const
@@ -51,18 +52,43 @@ Lookup::rule_symbol (Real height, Real width) const
   return bs;
 }
 
+Atom 
+Lookup::beam(Real &slope, Real width, Real y_thick) const
+{
+  if (postscript_global_b)
+    {
+      return ps_beam (slope, width, y_thick);
+    }
+  else
+    return tex_beam(slope, width);
+}
+
+Atom
+Lookup::ps_beam (Real  slope, Real width, Real y_thickness)const
+{
+  Atom ret;
+  String ps(String (width) + " "+ String(slope) 
+           + " " + String(y_thickness) + " draw_beam");
+  ret.tex_ = String("\\embeddedps{" + ps + "}");
+  ret.dim_[X_AXIS] = Interval(0, width);
+  ret.dim_[Y_AXIS] = Interval(0, slope * width + y_thickness);
+  return ret;
+}
+
 Atom
-Lookup::beam (Real &slope, Real width) const
+Lookup::tex_beam (Real &slope, Real width) const
 {
+  const Real MAX_SLOPE = 0.6;
+  const Real SLOPES = 20.0;
   int sidx = 0;
-  if (abs (slope) > 1.0)
+  if (abs (slope) > MAX_SLOPE)
     {
-      WARN << _("beam steeper than 1.0 (") << slope << ")\n";
-      slope = sign (slope);
+      WARN << _("beam too steep (") << slope << ")\n";
+      slope = sign (slope) * MAX_SLOPE;
     }
 
-  sidx = int (rint (slope *  20.0));
-  slope = sidx / 20.0;
+  sidx = int (rint (slope / MAX_SLOPE *  SLOPES));
+  slope = MAX_SLOPE * sidx / SLOPES;
 
   Interval xdims = (*symtables_p_)("beamslopes")->lookup ("slope").dim_[X_AXIS];
   Real min_wid = xdims[LEFT];