From a1a1c210b5429a37e82a8946aa460820c6bf91ba Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 23:23:44 +0000 Subject: [PATCH] lilypond-1.3.65 --- flower/direction.cc | 25 +++++ lily/include/slur-bezier-bow.hh | 25 +++++ lily/include/slur.hh | 7 +- lily/slur-bezier-bow.cc | 180 ++++++++++++++++++++++++++++++++ ly/declarations.ly | 3 + 5 files changed, 234 insertions(+), 6 deletions(-) create mode 100644 flower/direction.cc create mode 100644 lily/include/slur-bezier-bow.hh create mode 100644 lily/slur-bezier-bow.cc diff --git a/flower/direction.cc b/flower/direction.cc new file mode 100644 index 0000000000..aeddc311a2 --- /dev/null +++ b/flower/direction.cc @@ -0,0 +1,25 @@ +/* + direction.cc -- implement Direction + + source file of the GNU LilyPond music typesetter + + (c) 1998--2000 Han-Wen Nienhuys + + */ + +#include "direction.hh" + +String +direction_str (Direction d, Axis a) +{ + String s("center"); + if (a == Y_AXIS) + { + s =( d == UP ? "up" : "down"); + } + else if (a == X_AXIS) + { + s = (d == LEFT ? "left" : "right" ); + } + return s; +} diff --git a/lily/include/slur-bezier-bow.hh b/lily/include/slur-bezier-bow.hh new file mode 100644 index 0000000000..7fbbffd762 --- /dev/null +++ b/lily/include/slur-bezier-bow.hh @@ -0,0 +1,25 @@ +/* + slur-bezier-bow.hh -- declare Slur_bezier_bow + + source file of the GNU LilyPond music typesetter + + (c) 2000 Jan Nieuwenhuizen +*/ + +#ifndef SLUR_BEZIER_BOW_HH +#define SLUR_BEZIER_BOW_HH + +#include "bezier-bow.hh" + +class Slur_bezier_bow : public Bezier_bow +{ +public: + Slur_bezier_bow (Array encompass, Direction dir); + Array area_x_gradients_array (Real area); + void blow_fit (); + Real enclosed_area_f () const; + Real fit_factor () const; + void minimise_enclosed_area (Paper_def* paper_l, Real default_height); +}; + +#endif /* SLUR_BEZIER_BOW_HH */ diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 654bc45685..80b18fbfc7 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -26,17 +26,12 @@ public: virtual Array get_encompass_offset_arr () const; Bezier get_curve () const; - /* - JUNKME - */ - Drul_array dy_f_drul_; - Drul_array dx_f_drul_; - virtual Direction get_default_dir () const; SCM member_after_line_breaking (); static SCM after_line_breaking (SCM); virtual void do_add_processing (); Array get_rods () const; + Offset get_attachment (Direction dir) const; private: void de_uglyfy (Slur_bezier_bow* bb, Real default_height); diff --git a/lily/slur-bezier-bow.cc b/lily/slur-bezier-bow.cc new file mode 100644 index 0000000000..0dc7ba2418 --- /dev/null +++ b/lily/slur-bezier-bow.cc @@ -0,0 +1,180 @@ +/* + slur-bezier-bow.cc -- implement Slur_bezier_bow + + source file of the GNU LilyPond music typesetter + + (c) 2000 Jan Nieuwenhuizen +*/ + +#include "debug.hh" +#include "paper-def.hh" +#include "slur-bezier-bow.hh" +#include "main.hh" + +Slur_bezier_bow::Slur_bezier_bow (Array encompass, Direction dir) + : Bezier_bow (encompass, dir) +{ +} + +void +Slur_bezier_bow::blow_fit () +{ + Real len = curve_.control_[3][X_AXIS]; + Real h = curve_.control_[1][Y_AXIS] * fit_factor () / len; + curve_.control_[1][Y_AXIS] = h * len; + curve_.control_[2][Y_AXIS] = h * len; + curve_.assert_sanity (); +} + + +Real +Slur_bezier_bow::enclosed_area_f () const +{ + Real a = 0; + for (int i=0; i < encompass_.size (); i++) + { + Interval x; + Interval y; + if (i == 0) + { + x = Interval (0, encompass_[1][X_AXIS] / 2); + y = Interval (0, + curve_.get_other_coordinate (X_AXIS, + encompass_[1][X_AXIS] + / 2)); + } + else if (i == encompass_.size () - 1) + { + x = Interval ((encompass_[i-1][X_AXIS] + encompass_[i][X_AXIS])/2, + encompass_[i][X_AXIS]); + y = Interval (0, + (curve_.get_other_coordinate (X_AXIS, + (x[MIN] + x[MAX]) / 2))); + } + else + { + x = Interval ((encompass_[i-1][X_AXIS] + encompass_[i][X_AXIS]) / 2, + (encompass_[i][X_AXIS] + encompass_[i+1][X_AXIS]) / 2); + y = Interval (encompass_[i][Y_AXIS], + (curve_.get_other_coordinate (X_AXIS, x[MIN]) + + curve_.get_other_coordinate (X_AXIS, + (x[MIN] + x[MAX]) / 2) + + curve_.get_other_coordinate (X_AXIS, x[MAX])) / 3); + } + + Real da = x.length () * y.length (); + a += da; + } + return a; +} + +Array +Slur_bezier_bow::area_x_gradients_array (Real area) +{ + Real len = curve_.control_[3][X_AXIS]; + Real grow = len / 10.0; + Array da (2); + for (int i=0; i < 2; i++) + { + Real r = curve_.control_[i+1][X_AXIS]; + curve_.control_[i+1][X_AXIS] += grow; + da[i] = (enclosed_area_f () - area) / grow; + curve_.control_[i+1][X_AXIS] = r; + } + return da; +} + +void +Slur_bezier_bow::minimise_enclosed_area (Paper_def* paper_l, + Real default_height) +{ + Real length = curve_.control_[3][X_AXIS]; + Real sb = paper_l->get_var ("slur_beautiful"); + Real beautiful = length * default_height * sb; + + DEBUG_OUT << to_str ("Beautiful: %f\n", beautiful); + DEBUG_OUT << to_str ("Length: %f\n", length); + DEBUG_OUT << to_str ("D-height: %f\n", default_height); + DEBUG_OUT << to_str ("FitFac: %f\n", fit_factor ()); + + if (fit_factor () > 1.0) + blow_fit (); + + Real pct_c0 = paper_l->get_var ("bezier_pct_c0"); + Real pct_c3 = paper_l->get_var ("bezier_pct_c3"); + Real pct_in_max = paper_l->get_var ("bezier_pct_in_max"); + Real pct_out_max = paper_l->get_var ("bezier_pct_out_max"); + Real steps = paper_l->get_var ("bezier_area_steps"); + + for (int i=0; i < steps; i++) + { + Real area = enclosed_area_f (); + if (!i) + DEBUG_OUT << to_str ("Init area: %f\n", area); + + if (area <= beautiful) + break; + + Array da = area_x_gradients_array (area); + + // urg + Real pct = pct_c0 + pct_c3 * length * length * length; + pct *= (steps - i) / steps; + if (da[0] > 0 || da[1] < 0) + pct = pct x1 && encompass_[i][X_AXIS] < x2) + { + Real y = curve_.get_other_coordinate (X_AXIS, encompass_[i][X_AXIS]); + if (y>0) + { + Real f = encompass_[i][Y_AXIS] / y; + factor = factor >? f; + } + } + } + + + return factor; +} + + + + diff --git a/ly/declarations.ly b/ly/declarations.ly index e6f16c1539..ec640fb578 100644 --- a/ly/declarations.ly +++ b/ly/declarations.ly @@ -6,6 +6,9 @@ maxima = \duration #'( -3 0 ) #(eval-string (ly-gulp-file "generic-property.scm")) +% urg, move to basic property? +#(eval-string (ly-gulp-file "slur.scm")) + \include "nederlands.ly" % dutch \include "chord-modifiers.ly" \include "script.ly" -- 2.39.5