From: Johan Engelen Date: Wed, 28 Jul 2010 22:22:18 +0000 (+0200) Subject: powerstroke: add visually 'nice' interpolator, good enough for now X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=64e2d36a474bb4025cec7814ee056f13d471e5c7;p=inkscape.git powerstroke: add visually 'nice' interpolator, good enough for now --- 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);