From 64e2d36a474bb4025cec7814ee056f13d471e5c7 Mon Sep 17 00:00:00 2001 From: Johan Engelen Date: Thu, 29 Jul 2010 00:22:18 +0200 Subject: [PATCH] powerstroke: add visually 'nice' interpolator, good enough for now --- src/live_effects/lpe-powerstroke.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index af5739b32..addddd06f 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -97,6 +97,28 @@ private: CubicBezierFit& operator=(const CubicBezierFit&); }; +/// @todo invent name for this class +class CubicBezierJohan : public Interpolator { +public: + CubicBezierJohan() {}; + virtual ~CubicBezierJohan() {}; + + virtual Path interpolateToPath(std::vector points) { + Path fit; + fit.start(points.at(0)); + for (unsigned int i = 1; i < points.size(); ++i) { + Point p0 = points.at(i-1); + Point p1 = points.at(i); + Point dx = Point(p1[X] - p0[X], 0); + fit.appendNew(p0+0.2*dx, p1-0.2*dx, p1); + } + return fit; + }; + +private: + CubicBezierJohan(const CubicBezierJohan&); + CubicBezierJohan& operator=(const CubicBezierJohan&); +}; } //namespace Interpolate } //namespace Geom @@ -159,7 +181,7 @@ LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise > const & } // create stroke path where points (x,y) = (t, offset) - Geom::Interpolate::Linear interpolator; + Geom::Interpolate::CubicBezierJohan interpolator; Path strokepath = interpolator.interpolateToPath(ts); Path mirroredpath = strokepath.reverse() * Geom::Scale(1,-1); strokepath.append(mirroredpath, Geom::Path::STITCH_DISCONTINUOUS); -- 2.30.2