summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiam P. White <inkscapebronyat-signgmaildotcom>2014-03-23 21:25:49 +0000
committerLiam P. White <inkscapebronyat-signgmaildotcom>2014-03-23 21:25:49 +0000
commit7d6a2eac770b159a51183add6917eaec36729d80 (patch)
tree8a2f2d7b464a316e389891e1936e16f95a9ef7fa /src
parentUpdate to trunk (diff)
downloadinkscape-7d6a2eac770b159a51183add6917eaec36729d80.tar.gz
inkscape-7d6a2eac770b159a51183add6917eaec36729d80.zip
tiny bugfix for Taper Strokes
(bzr r13090.1.30)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-taperstroke.cpp54
-rwxr-xr-xsrc/live_effects/pathoutlineprovider.cpp33
-rw-r--r--src/live_effects/pathoutlineprovider.h1
3 files changed, 68 insertions, 20 deletions
diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp
index a862417d7..0e709f3ac 100644
--- a/src/live_effects/lpe-taperstroke.cpp
+++ b/src/live_effects/lpe-taperstroke.cpp
@@ -324,40 +324,54 @@ Geom::PathVector LPETaperStroke::doEffect_path(Geom::PathVector const& path_in)
if (true) {
Geom::PathVector real_pathv;
+ Geom::Path real_path;
//Construct the pattern (pat_str stands for pattern string)
- char pat_str[200];
- sprintf(pat_str, "M 1,0 1,1 C %5.5f,1 0,0.5 0,0.5 0,0.5 %5.5f,0 1,0 Z", 1 - (double)smoothing, 1 - (double)smoothing);
- Geom::PathVector pat_vec = sp_svg_read_pathv(pat_str);
+ std::stringstream pat_str;
+ pat_str << "M 1,0 1,1 C " << 1 - (double)smoothing << ",1 0,0.5 0,0.5 0,0.5 " << 1 - double(smoothing) << ",0 1,0";
+
+ Geom::PathVector pat_vec = sp_svg_read_pathv(pat_str.str().c_str());
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2;
pwd2.concat(stretch_along(pathv_out[0].toPwSb(), pat_vec[0], line_width));
- real_pathv.push_back(path_from_piecewise(pwd2, 0.001)[0]);
+ Geom::Path throwaway_path = path_from_piecewise(pwd2, 0.001)[0].reverse();
+ throwaway_path.erase_last();
- Geom::PathVector sht_path;
- sht_path.push_back(pathv_out[1]);
- sht_path = Outline::PathVectorOutline(sht_path, line_width, butt_straight, static_cast<join_typ>(join_type.get_value()) , miter_limit);
+ real_path.append(throwaway_path); //wtf
- real_pathv.push_back(sht_path[0]);
+ throwaway_path = Outline::PathOutsideOutline(pathv_out[1],
+ line_width, static_cast<LineJoinType>(join_type.get_value()), miter_limit);
+
+ throwaway_path.setInitial(real_path.finalPoint());
+ real_path.append(throwaway_path);
- char pat_str_1[200];
- sprintf(pat_str_1, "M 0,0 0,1 C %5.5f,1 1,0.5 1,0.5 1,0.5 %5.5f,0 0,0 Z", (double)smoothing, (double)smoothing);
- pat_vec = sp_svg_read_pathv(pat_str_1);
+ std::stringstream pat_str_1;
+ pat_str_1 << "M 0,0 0,1 C " << (double)smoothing << ",1 1,0.5 1,0.5 1,0.5 " << double(smoothing) << ",0 0,0";
+ pat_vec = sp_svg_read_pathv(pat_str_1.str().c_str());
pwd2 = Geom::Piecewise<Geom::D2<Geom::SBasis> > ();
pwd2.concat(stretch_along(pathv_out[2].toPwSb(), pat_vec[0], line_width));
- real_pathv.push_back(path_from_piecewise(pwd2, 0.001)[0].reverse());
- //clever union
- //Geom::Shape shape1 = Geom::sanitize(Geom::PathVector(1, real_pathv[0]));
- //Geom::Shape shape2 = Geom::sanitize(Geom::PathVector(1, real_pathv[1]));
- //Geom::Shape shape3 = Geom::boolop(shape1, shape2, Geom::BOOLOP_UNION);
+ throwaway_path = Geom::Path();
+ throwaway_path = path_from_piecewise(pwd2, 0.001)[0];
+ throwaway_path.setInitial(real_path.finalPoint());
+ real_path.append(throwaway_path);
+
+ throwaway_path = Geom::Path();
+ throwaway_path = Outline::PathOutsideOutline(pathv_out[1].reverse(),
+ line_width, static_cast<LineJoinType>(join_type.get_value()), miter_limit);
+
+ //throwaway_path = throwaway_path.reverse();
+ throwaway_path.setInitial(real_path.finalPoint());
+
+ real_path.append(throwaway_path);
+ //real_path.close();
+
+ real_pathv.push_back(real_path);
- //shape2 = Geom::sanitize(Geom::PathVector(1, real_pathv[2]));
- //shape1 = Geom::boolop(shape3, shape2, Geom::BOOLOP_UNION);
+ //real_pathv.push_back(path_from_piecewise(pwd2, 0.001)[0].reverse());
- //real_pathv = Geom::desanitize(shape1);
return real_pathv;
}
@@ -383,7 +397,7 @@ Geom::PathVector LPETaperStroke::doEffect_simplePath(Geom::PathVector const & pa
trimmed_start.append(path_in[0] [i]);
}
- #define OVERLAP (0.001 / (line_width < 1 ? 1 : line_width))
+ #define OVERLAP 0 /*(0.001 / (line_width < 1 ? 1 : line_width))*/
trimmed_start.append(*subdivide_at(curve_start, (attach_start - loc) + OVERLAP, true));
curve_start = subdivide_at(curve_start, attach_start - loc, false);
diff --git a/src/live_effects/pathoutlineprovider.cpp b/src/live_effects/pathoutlineprovider.cpp
index e62f516c9..302756c7c 100755
--- a/src/live_effects/pathoutlineprovider.cpp
+++ b/src/live_effects/pathoutlineprovider.cpp
@@ -825,6 +825,39 @@ Geom::PathVector PathVectorOutline(Geom::PathVector const & path_in, double line
#undef miter_lim
return path_out;
}
+Geom::Path PathOutsideOutline(Geom::Path const & path_in, double line_width, LineJoinType linejoin_type, double miter_limit)
+{
+
+ #define miter_lim fabs(line_width * miter_limit)
+
+ Geom::Path path_out;
+
+ if (linejoin_type <= LINEJOIN_POINTY || path_in.size() <= 1) {
+
+ Geom::PathVector * pathvec;
+
+ Path path_tangent = Path();
+ Path path_outline = Path();
+ path_outline.LoadPath(path_in, Geom::Affine(), false, false);
+ path_outline.OutsideOutline(&path_tangent, line_width / 2, static_cast<join_typ>(linejoin_type), butt_straight, miter_lim);
+
+ pathvec = path_tangent.MakePathVector();
+ path_out = pathvec[0]/* deref pointer */[0]/*actual object ref*/;
+ delete pathvec;
+ return path_out;
+ }
+ else if (linejoin_type == LINEJOIN_REFLECTED) {
+ //reflected half outline
+ Geom::PathVector pathvec; pathvec.push_back(path_in);
+ path_out = half_outline(path_in, line_width, butt_straight, miter_lim);
+ return path_out;
+ }
+ else if (linejoin_type == LINEJOIN_EXTRAPOLATED) {
+ path_out = half_outline_extrp(path_in, line_width, butt_straight, miter_lim);
+ return path_out;
+ }
+ return path_out;
+}
} // namespace Outline
diff --git a/src/live_effects/pathoutlineprovider.h b/src/live_effects/pathoutlineprovider.h
index 1a363c35b..4133f47c2 100644
--- a/src/live_effects/pathoutlineprovider.h
+++ b/src/live_effects/pathoutlineprovider.h
@@ -20,6 +20,7 @@ namespace Outline
Geom::PathVector outlinePath(const Geom::PathVector& path_in, double line_width, JoinType join, ButtType butt, double miter_lim);
Geom::PathVector outlinePath_extr(const Geom::PathVector& path_in, double line_width, LineJoinType join, ButtType butt, double miter_lim);
+ Geom::Path PathOutsideOutline(Geom::Path const & path_in, double line_width, LineJoinType linejoin_type, double miter_limit);
}
#endif // _SEEN_PATH_OUTLINE_H