From: jfbarraud Date: Sun, 9 Mar 2008 01:09:57 +0000 (+0000) Subject: skeletal-stroke: offset parameters are back again... optionaly proportional to patter... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8c8f0c85c103512b18656764a3fc574fa043cd27;p=inkscape.git skeletal-stroke: offset parameters are back again... optionaly proportional to pattern size. --- diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 2590cda82..a82da903b 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -33,7 +33,7 @@ namespace LivePathEffect { LPEKnot::LPEKnot(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: - interruption_width(_("Interruption width"), _("Howmuch the lower strand is obscured by the upper."), "interruption_width", &wr, this, 1.2) + interruption_width(_("Interruption width"), _("Howmuch the lower strand is obscured by the upper."), "interruption_width", &wr, this, 10) { // register all your parameters here, so Inkscape knows which parameters this effect has: registerParameter( dynamic_cast(&interruption_width) ); diff --git a/src/live_effects/lpe-skeletalstrokes.cpp b/src/live_effects/lpe-skeletalstrokes.cpp index 6ba9ac65c..0f8e013b8 100644 --- a/src/live_effects/lpe-skeletalstrokes.cpp +++ b/src/live_effects/lpe-skeletalstrokes.cpp @@ -63,18 +63,20 @@ LPESkeletalStrokes::LPESkeletalStrokes(LivePathEffectObject *lpeobject) : copytype(_("Pattern copies"), _("How many pattern copies to place along the skeleton path"), "copytype", SkelCopyTypeConverter, &wr, this, SSCT_SINGLE_STRETCHED), prop_scale(_("Width"), _("Width of the pattern"), "prop_scale", &wr, this, 1), scale_y_rel(_("Width in units of length"), _("Scale the width of the pattern in units of its length"), "scale_y_rel", &wr, this, false), - spacing(_("Spacing"), _("Space between copies of the pattern"), "spacing", &wr, this, 0), + spacing(_("Spacing"), _("Space between copies of the pattern. Negative values allowed, but are limited to -90% of pattern width."), "spacing", &wr, this, 0), normal_offset(_("Normal offset"), "", "normal_offset", &wr, this, 0), tang_offset(_("Tangential offset"), "", "tang_offset", &wr, this, 0), + prop_units(_("Offsets in % of pattern size"), "Spacing, tangential and normal offset are expressed in % of width/height", "prop_units", &wr, this, false), vertical_pattern(_("Pattern is vertical"), "Rotate pattern 90 deg before applying", "vertical_pattern", &wr, this, false) { registerParameter( dynamic_cast(&pattern) ); registerParameter( dynamic_cast(©type) ); registerParameter( dynamic_cast(&prop_scale) ); registerParameter( dynamic_cast(&scale_y_rel) ); -// registerParameter( dynamic_cast(&spacing) ); -// registerParameter( dynamic_cast(&normal_offset) ); -// registerParameter( dynamic_cast(&tang_offset) ); + registerParameter( dynamic_cast(&spacing) ); + registerParameter( dynamic_cast(&normal_offset) ); + registerParameter( dynamic_cast(&tang_offset) ); + registerParameter( dynamic_cast(&prop_units) ); registerParameter( dynamic_cast(&vertical_pattern) ); prop_scale.param_set_digits(3); @@ -104,36 +106,73 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise > & pw D2 > patternd2 = make_cuts_independant(pattern); Piecewise x = vertical_pattern.get_value() ? Piecewise(patternd2[1]) : Piecewise(patternd2[0]); Piecewise y = vertical_pattern.get_value() ? Piecewise(patternd2[0]) : Piecewise(patternd2[1]); - Interval pattBnds = bounds_exact(x); - x -= pattBnds.min(); + Interval pattBndsX = bounds_exact(x); + x -= pattBndsX.min(); Interval pattBndsY = bounds_exact(y); y -= pattBndsY.middle(); - int nbCopies = int(uskeleton.cuts.back()/pattBnds.extent()); - double scaling = 1; + double xspace = spacing; + double noffset = normal_offset; + double toffset = tang_offset; + if (prop_units.get_value()){ + xspace *= pattBndsX.extent(); + noffset *= pattBndsY.extent(); + toffset *= pattBndsX.extent(); + } + + //Prevent more than 90% overlap... + if (xspace < -pattBndsX.extent()*.9) { + xspace = -pattBndsX.extent()*.9; + } + //TODO: dynamical update of parameter ranges? + //if (prop_units.get_value()){ + // spacing.param_set_range(-.9, NR_HUGE); + // }else{ + // spacing.param_set_range(-pattBndsX.extent()*.9, NR_HUGE); + // } + + + + + y+=noffset; + + int nbCopies = 0; + double scaling = 1; switch(type) { case SSCT_REPEATED: + nbCopies = floor((uskeleton.domain().extent() - tang_offset + xspace)/(pattBndsX.extent()+xspace)); + pattBndsX = Interval(pattBndsX.min(),pattBndsX.max()+xspace); break; case SSCT_SINGLE: - nbCopies = (nbCopies > 0) ? 1 : 0; + nbCopies = (tang_offset + pattBndsX.extent() < uskeleton.domain().extent()) ? 1 : 0; break; case SSCT_SINGLE_STRETCHED: nbCopies = 1; - scaling = uskeleton.cuts.back()/pattBnds.extent(); + scaling = (uskeleton.domain().extent() - tang_offset)/pattBndsX.extent(); break; case SSCT_REPEATED_STRETCHED: - scaling = uskeleton.cuts.back()/(((double)nbCopies)*pattBnds.extent()); + // if uskeleton is closed: + if(pwd2_in.segs.front().at0() == pwd2_in.segs.back().at1()){ + nbCopies = std::floor((uskeleton.domain().extent() - tang_offset)/(pattBndsX.extent()+xspace)); + pattBndsX = Interval(pattBndsX.min(),pattBndsX.max()+xspace); + scaling = (uskeleton.domain().extent() - tang_offset)/(((double)nbCopies)*pattBndsX.extent()); + // if not closed: no space at the end + }else{ + nbCopies = std::floor((uskeleton.domain().extent() - tang_offset + xspace)/(pattBndsX.extent()+xspace)); + pattBndsX = Interval(pattBndsX.min(),pattBndsX.max()+xspace); + scaling = (uskeleton.domain().extent() - tang_offset)/(((double)nbCopies)*pattBndsX.extent() - xspace); + } break; default: return pwd2_in; }; - double pattWidth = pattBnds.extent() * scaling; + double pattWidth = pattBndsX.extent() * scaling; if (scaling != 1.0) { x*=scaling; @@ -143,6 +182,8 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise > & pw } else { if (prop_scale != 1.0) y *= prop_scale; } + x += tang_offset; + double offs = 0; Piecewise > output; diff --git a/src/live_effects/lpe-skeletalstrokes.h b/src/live_effects/lpe-skeletalstrokes.h index f57e8f2ca..bab2239b3 100644 --- a/src/live_effects/lpe-skeletalstrokes.h +++ b/src/live_effects/lpe-skeletalstrokes.h @@ -42,6 +42,7 @@ private: ScalarParam spacing; ScalarParam normal_offset; ScalarParam tang_offset; + BoolParam prop_units; BoolParam vertical_pattern; void on_pattern_pasted();