From 6ae65962287820b2e9c19a1bd46de815606740af Mon Sep 17 00:00:00 2001 From: johanengelen Date: Fri, 23 Nov 2007 23:18:12 +0000 Subject: [PATCH] LPE add experimental width control to bend path! --- src/live_effects/lpe-pathalongpath.cpp | 25 +++++++++++++++++-------- src/live_effects/lpe-pathalongpath.h | 5 ++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/live_effects/lpe-pathalongpath.cpp b/src/live_effects/lpe-pathalongpath.cpp index 7138b6faa..e552bdaad 100644 --- a/src/live_effects/lpe-pathalongpath.cpp +++ b/src/live_effects/lpe-pathalongpath.cpp @@ -63,22 +63,17 @@ static const Util::EnumDataConverter PAPCopyTypeConverter(PAPCopyTy LPEPathAlongPath::LPEPathAlongPath(LivePathEffectObject *lpeobject) : Effect(lpeobject), bend_path(_("Bend path"), _("Path along which to bend the original path"), "bendpath", &wr, this, "M0,0 L1,0"), + width_path(_("Width path"), _("..."), "widthpath", &wr, this, "M0,0 L1,0"), copytype(_("Path copies"), _("How many copies to place along the skeleton path"), "copytype", PAPCopyTypeConverter, &wr, this, PAPCT_SINGLE_STRETCHED), prop_scale(_("Width"), _("Width of the path"), "prop_scale", &wr, this, 1), scale_y_rel(_("Width in units of length"), _("Scale the width of the path in units of its length"), "scale_y_rel", &wr, this, false), - spacing(_("Spacing"), _("Space between copies of the path"), "spacing", &wr, this, 0), - normal_offset(_("Normal offset"), "", "normal_offset", &wr, this, 0), - tang_offset(_("Tangential offset"), "", "tang_offset", &wr, this, 0), vertical_pattern(_("Original path is vertical"), "", "vertical", &wr, this, false) { registerParameter( dynamic_cast(&bend_path) ); + registerParameter( dynamic_cast(&width_path) ); registerParameter( dynamic_cast(©type) ); registerParameter( dynamic_cast(&prop_scale) ); registerParameter( dynamic_cast(&scale_y_rel) ); -//These parameters have not been implemented yet: -// registerParameter( dynamic_cast(&spacing) ); -// registerParameter( dynamic_cast(&normal_offset) ); -// registerParameter( dynamic_cast(&tang_offset) ); registerParameter( dynamic_cast(&vertical_pattern) ); prop_scale.param_set_digits(3); @@ -151,10 +146,15 @@ LPEPathAlongPath::doEffect_pwd2 (Geom::Piecewise > & pwd2 if (prop_scale != 1.0) y *= prop_scale; } + Piecewise > widthpwd2 = arc_length_parametrization(Piecewise >(width_path),2,.1); + D2 > widthd2pw = make_cuts_independant(widthpwd2); + Piecewise width = (Piecewise(widthd2pw[Y]) - uskeletonbounds[Y].middle()) * wfactor; + + double offs = 0; Piecewise > output; for (int i=0; i( end ); bend_path.param_set_and_write_new_value( path.toPwSb() ); + + Point startw(bndsX.min(), bndsY.max()); + Point endw(bndsX.max(), bndsY.max()); + Geom::Path pathw; + pathw.start( startw ); + pathw.appendNew( endw ); + width_path.param_set_and_write_new_value( pathw.toPwSb() ); + + wfactor = 1/(startw[Y]-start[Y]); } } // namespace LivePathEffect diff --git a/src/live_effects/lpe-pathalongpath.h b/src/live_effects/lpe-pathalongpath.h index d404e0f67..b75d5e227 100644 --- a/src/live_effects/lpe-pathalongpath.h +++ b/src/live_effects/lpe-pathalongpath.h @@ -36,13 +36,12 @@ public: private: PathParam bend_path; + PathParam width_path; EnumParam copytype; ScalarParam prop_scale; BoolParam scale_y_rel; - ScalarParam spacing; - ScalarParam normal_offset; - ScalarParam tang_offset; BoolParam vertical_pattern; + double wfactor; void on_pattern_pasted(); -- 2.30.2