From: jfbarraud Date: Tue, 5 Feb 2008 00:51:50 +0000 (+0000) Subject: lpe-skeletal-stroke: make spacing and normal_offset parameters do something... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0dfb4a9cdc4bd6fbfa83d4e2c67209d7ec0f2931;p=inkscape.git lpe-skeletal-stroke: make spacing and normal_offset parameters do something... --- diff --git a/src/live_effects/lpe-skeletalstrokes.cpp b/src/live_effects/lpe-skeletalstrokes.cpp index 6ba9ac65c..ea1610546 100644 --- a/src/live_effects/lpe-skeletalstrokes.cpp +++ b/src/live_effects/lpe-skeletalstrokes.cpp @@ -72,13 +72,14 @@ LPESkeletalStrokes::LPESkeletalStrokes(LivePathEffectObject *lpeobject) : 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(&vertical_pattern) ); prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); + tang_offset.param_set_range(0, NR_HUGE); } LPESkeletalStrokes::~LPESkeletalStrokes() @@ -105,28 +106,37 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise > & pw 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(); + x -= pattBnds.min(); Interval pattBndsY = bounds_exact(y); - y -= pattBndsY.middle(); + y -= pattBndsY.middle()+normal_offset; - int nbCopies = int(uskeleton.cuts.back()/pattBnds.extent()); + //Prevent more than 90% overlap... + if (spacing < -pattBnds.extent()*.9) { + spacing.param_set_value(-pattBnds.extent()*.9); + } + + int nbCopies = 0; double scaling = 1; switch(type) { case SSCT_REPEATED: + nbCopies = floor((uskeleton.domain().extent() - tang_offset + spacing)/(pattBnds.extent()+spacing)); + pattBnds = Interval(pattBnds.min(),pattBnds.max()+spacing); break; case SSCT_SINGLE: - nbCopies = (nbCopies > 0) ? 1 : 0; + nbCopies = (tang_offset + pattBnds.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)/pattBnds.extent(); break; case SSCT_REPEATED_STRETCHED: - scaling = uskeleton.cuts.back()/(((double)nbCopies)*pattBnds.extent()); + nbCopies = std::floor((uskeleton.domain().extent() - tang_offset + spacing)/(pattBnds.extent()+spacing)); + pattBnds = Interval(pattBnds.min(),pattBnds.max()+spacing); + scaling = (uskeleton.domain().extent() - tang_offset)/(((double)nbCopies)*pattBnds.extent() - spacing); break; default: @@ -143,6 +153,7 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise > & pw } else { if (prop_scale != 1.0) y *= prop_scale; } + x += tang_offset; double offs = 0; Piecewise > output;