summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-08-30 20:31:27 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-08-30 20:31:27 +0000
commitd4dbeead9cc6bdf714ecf4cb3fabd0962c73c216 (patch)
treed9c305c11ffa07a144824ce286620f2bf18fa7cf /src
parentAdd commentary to warn about how to initialize translatable enums (diff)
downloadinkscape-d4dbeead9cc6bdf714ecf4cb3fabd0962c73c216.tar.gz
inkscape-d4dbeead9cc6bdf714ecf4cb3fabd0962c73c216.zip
Added freedom of strokepath for the Curve Stitching LPE
(bzr r3626)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-curvestitch.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp
index 1769a40a1..b0e8dc8f7 100644
--- a/src/live_effects/lpe-curvestitch.cpp
+++ b/src/live_effects/lpe-curvestitch.cpp
@@ -24,6 +24,8 @@
#include <2geom/bezier-to-sbasis.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/d2.h>
+#include <2geom/matrix.h>
+
#include "ui/widget/scalar.h"
#include "libnr/nr-values.h"
@@ -35,14 +37,15 @@ using namespace Geom;
LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- strokepath(_("Stroke path"), _("The path that will be stroked, whatever, think of good text here."), "strokepath", &wr, this, "M0,0 L1,1"),
+ strokepath(_("Stroke path"), _("The path that will be stroked, whatever, think of good text here."), "strokepath", &wr, this, "M0,0 L1,0"),
nrofpaths(_("Nr of paths"), _("The number of paths that will be generated."), "count", &wr, this, 5),
startpoint_variation(_("Startpoint variation"), _("..."), "startpoint_variation", &wr, this, 0),
endpoint_variation(_("Endpoint variation"), _("..."), "endpoint_variation", &wr, this, 0)
{
registerParameter( dynamic_cast<Parameter *>(&nrofpaths) );
-// registerParameter( dynamic_cast<Parameter *>(&startpoint_variation) );
-// registerParameter( dynamic_cast<Parameter *>(&endpoint_variation) );
+ registerParameter( dynamic_cast<Parameter *>(&startpoint_variation) );
+ registerParameter( dynamic_cast<Parameter *>(&endpoint_variation) );
+ registerParameter( dynamic_cast<Parameter *>(&strokepath) );
nrofpaths.param_make_integer();
nrofpaths.param_set_range(2, NR_HUGE);
@@ -60,6 +63,12 @@ std::vector<Geom::Path>
LPECurveStitch::doEffect (std::vector<Geom::Path> & path_in)
{
if (path_in.size() >= 2) {
+ D2<Piecewise<SBasis> > stroke = make_cuts_independant(strokepath);
+ Interval bndsStroke = bounds_exact(stroke[0]);
+ gdouble scaling = bndsStroke.max() - bndsStroke.min();
+ Interval bndsStrokeY = bounds_exact(stroke[1]);
+ Point stroke_origin(bndsStroke.min(), (bndsStrokeY.max()+bndsStrokeY.min())/2);
+
std::vector<Geom::Path> path_out (nrofpaths);
// do this for all permutations if there are more than 2 paths? realllly cool!
@@ -78,9 +87,14 @@ LPECurveStitch::doEffect (std::vector<Geom::Path> & path_in)
start = start + g_random_double_range(0, startpoint_variation) * (end - start);
if (endpoint_variation != 0)
end = end + g_random_double_range(0, endpoint_variation) * (end - start);
-
- path_out[i].start( start );
- path_out[i].appendNew<LineSegment>( end );
+
+ Matrix transform;
+ transform.setXAxis( (end-start) / scaling );
+ transform.setYAxis( rot90(unit_vector(end-start)));
+ transform.setTranslation( start );
+ Piecewise<D2<SBasis> > pwd2_out = (strokepath-stroke_origin) * transform;
+ std::vector<Path> result = Geom::path_from_piecewise(pwd2_out, LPE_CONVERSION_TOLERANCE);
+ path_out[i] = result[0];
tA += incrementA;
tB += incrementB;
}