summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-06-18 08:34:47 +0000
committerjabiertxof <info@marker.es>2016-06-18 08:34:47 +0000
commit2a97e646577aa34a4ec595d183d0b59dd79e3349 (patch)
treec85ca26652f12505e028993459073000e6a2e78e /src/live_effects
parentattemp to simplify doeffect code on fillet chamfer (diff)
parent[Bug #1454910] Compressed SVG with media error. (diff)
downloadinkscape-2a97e646577aa34a4ec595d183d0b59dd79e3349.tar.gz
inkscape-2a97e646577aa34a4ec595d183d0b59dd79e3349.zip
update to trunk
(bzr r13645.1.160)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-powerstroke.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index 03102a84a..66c8776b5 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -35,6 +35,7 @@
#include <2geom/ellipse.h>
#include <2geom/circle.h>
#include <2geom/math-utils.h>
+#include "helper/geom.h"
#include <math.h>
#include "spiro.h"
@@ -205,14 +206,13 @@ LPEPowerStroke::~LPEPowerStroke()
}
-
void
LPEPowerStroke::doOnApply(SPLPEItem const* lpeitem)
{
- if (SP_IS_SHAPE(lpeitem)) {
+ if (SP_IS_SHAPE(lpeitem) && offset_points.data().empty()) {
SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem);
std::vector<Geom::Point> points;
- Geom::PathVector const &pathv = SP_SHAPE(lpeitem)->_curve->get_pathvector();
+ Geom::PathVector const &pathv = pathv_to_linear_and_cubic_beziers(SP_SHAPE(lpeitem)->_curve->get_pathvector());
double width = (lpeitem && lpeitem->style) ? lpeitem->style->stroke_width.computed / 2 : 1.;
SPCSSAttr *css = sp_repr_css_attr_new ();
@@ -565,12 +565,11 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
if (path_in.empty()) {
return path_out;
}
-
- // for now, only regard first subpath and ignore the rest
- Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = path_in[0].toPwSb();
-
+ Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers(path_in);
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = pathv[0].toPwSb();
Piecewise<D2<SBasis> > der = derivative(pwd2_in);
- Piecewise<D2<SBasis> > n = rot90(unitVector(der));
+ Piecewise<D2<SBasis> > n = unitVector(der,0.0001);
+ n = rot90(n);
offset_points.set_pwd2(pwd2_in, n);
LineCapType end_linecap = static_cast<LineCapType>(end_linecap_type.get_value());
@@ -583,7 +582,7 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
if (sort_points) {
sort(ts.begin(), ts.end(), compare_offsets);
}
- if (path_in[0].closed()) {
+ if (pathv[0].closed()) {
// add extra points for interpolation between first and last point
Point first_point = ts.front();
Point last_point = ts.back();
@@ -605,7 +604,6 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
for (std::size_t i = 0, e = ts.size(); i < e; ++i) {
ts[i][Geom::X] *= xcoord_scaling;
}
-
// create stroke path where points (x,y) := (t, offset)
Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value()));
if (Geom::Interpolate::CubicBezierJohan *johan = dynamic_cast<Geom::Interpolate::CubicBezierJohan*>(interpolator)) {
@@ -631,7 +629,6 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
x = portion(x, rtsmin.at(0), rtsmax.at(0));
y = portion(y, rtsmin.at(0), rtsmax.at(0));
}
-
LineJoinType jointype = static_cast<LineJoinType>(linejoin_type.get_value());
Piecewise<D2<SBasis> > pwd2_out = compose(pwd2_in,x) + y*compose(n,x);
@@ -639,8 +636,7 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE);
Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, reverse(y), jointype, miter_limit, LPE_CONVERSION_TOLERANCE);
-
- if (path_in[0].closed()) {
+ if (pathv[0].closed()) {
fixed_path.close(true);
path_out.push_back(fixed_path);
fixed_mirrorpath.close(true);
@@ -684,7 +680,6 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
}
fixed_path.append(fixed_mirrorpath);
-
switch (start_linecap) {
case LINECAP_ZERO_WIDTH:
// do nothing
@@ -720,11 +715,9 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
break;
}
}
-
fixed_path.close(true);
path_out.push_back(fixed_path);
}
-
return path_out;
}