summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 475f799)
raw | patch | inline | side by side (parent: 475f799)
author | Johan Engelen <goejendaagh@zonnet.nl> | |
Tue, 27 Jul 2010 20:30:10 +0000 (22:30 +0200) | ||
committer | Johan Engelen <goejendaagh@zonnet.nl> | |
Tue, 27 Jul 2010 20:30:10 +0000 (22:30 +0200) |
src/live_effects/lpe-powerstroke.cpp | patch | blob | history | |
src/live_effects/lpe-powerstroke.h | patch | blob | history |
index da2b9d6a92c96a1b74fbbad1d7b68270e25243f1..cb45e0518faba0f4d4052534c44fc070ce680444 100644 (file)
LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this)
+ offset_points(_("Offset points"), _("Offset points"), "offset_points", &wr, this),
+ sort_points(_("Sort points"), _("Sort offset points according to their time value along the curve."), "sort_points", &wr, this, true)
{
show_orig_path = true;
registerParameter( dynamic_cast<Parameter *>(&offset_points) );
+ registerParameter( dynamic_cast<Parameter *>(&sort_points) );
}
LPEPowerStroke::~LPEPowerStroke()
pwd2.continuousConcat(cap_pwd2);
}
+static bool compare_offsets (Geom::Point first, Geom::Point second)
+{
+ return first[Geom::X] <= second[Geom::X];
+}
+
+
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEPowerStroke::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
using namespace Geom;
+ // perhaps use std::list instead of std::vector?
std::vector<Geom::Point> ts(offset_points.data().size());
for (unsigned int i; i < ts.size(); ++i) {
double offset = L2(pwd2_in.valueAt(t) - offset_points.data().at(i));
ts.at(i) = Geom::Point(t, offset);
}
+ if (sort_points) {
+ sort(ts.begin(), ts.end(), compare_offsets);
+ }
// create stroke path where points (x,y) = (t, offset)
Path strokepath;
index 66b2ab89fcf351adde321603afa31318ab0f7b41..6c208fda45a18c86d53058c9f8eced067b850227 100644 (file)
#define INKSCAPE_LPE_POWERSTROKE_H
#include "live_effects/effect.h"
-#include "live_effects/parameter/point.h"
+#include "live_effects/parameter/bool.h"
#include "live_effects/parameter/powerstrokepointarray.h"
namespace Inkscape {
private:
PowerStrokePointArrayParam offset_points;
+ BoolParam sort_points;
LPEPowerStroke(const LPEPowerStroke&);
LPEPowerStroke& operator=(const LPEPowerStroke&);