diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2010-07-28 22:22:18 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2010-07-28 22:22:18 +0000 |
| commit | eb7cb50faa8dd87fd507d3d496767b735401d0d5 (patch) | |
| tree | 64ad3613a3d495586f8677fddc7937d5fd6f0b21 /src | |
| parent | powerstroke: code only, added bad interpolator (diff) | |
| download | inkscape-eb7cb50faa8dd87fd507d3d496767b735401d0d5.tar.gz inkscape-eb7cb50faa8dd87fd507d3d496767b735401d0d5.zip | |
powerstroke: add visually 'nice' interpolator, good enough for now
(bzr r9669)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
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<Point> 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<CubicBezier>(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<Geom::D2<Geom::SBasis> > 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); |
