lpe-curvestitch.cpp revision 5c45bb188ab729e501e48732842cb9de6a9813be
/** \file
* LPE Curve Stitching implementation, used as an example for a base starting class
* when implementing new LivePathEffects.
*
*/
/*
* Authors:
* Johan Engelen
*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-curvestitch.h"
#include "sp-item.h"
#include "sp-path.h"
namespace Inkscape {
namespace LivePathEffect {
using namespace Geom;
strokepath(_("Stitch path:"), _("The path that will be used as stitch."), "strokepath", &wr, this, "M0,0 L1,0"),
nrofpaths(_("N_umber of paths:"), _("The number of paths that will be generated."), "count", &wr, this, 5),
startpoint_edge_variation(_("Sta_rt edge variance:"), _("The amount of random jitter to move the start points of the stitches inside & outside the guide path"), "startpoint_edge_variation", &wr, this, 0),
startpoint_spacing_variation(_("Sta_rt spacing variance:"), _("The amount of random shifting to move the start points of the stitches back & forth along the guide path"), "startpoint_spacing_variation", &wr, this, 0),
endpoint_edge_variation(_("End ed_ge variance:"), _("The amount of randomness that moves the end points of the stitches inside & outside the guide path"), "endpoint_edge_variation", &wr, this, 0),
endpoint_spacing_variation(_("End spa_cing variance:"), _("The amount of random shifting to move the end points of the stitches back & forth along the guide path"), "endpoint_spacing_variation", &wr, this, 0),
prop_scale(_("Scale _width:"), _("Scale the width of the stitch path"), "prop_scale", &wr, this, 1),
scale_y_rel(_("Scale _width relative to length"), _("Scale the width of the stitch path relative to its length"), "scale_y_rel", &wr, this, false)
{
}
{
}
{
if (!bndsStroke && !bndsStrokeY) {
return path_in;
}
// do this for all permutations (ii,jj) if there are more than 2 paths? realllly cool!
{
Piecewise<D2<SBasis> > A = arc_length_parametrization(Piecewise<D2<SBasis> >(path_in[ii].toPwSb()),2,.1);
Piecewise<D2<SBasis> > B = arc_length_parametrization(Piecewise<D2<SBasis> >(path_in[jj].toPwSb()),2,.1);
for (int i = 0; i < nrofpaths; i++) {
if (startpoint_edge_variation.get_value() != 0)
start = start + (startpoint_edge_variation - startpoint_edge_variation.get_value()/2) * (end - start);
if (endpoint_edge_variation.get_value() != 0)
if (scale_y_rel.get_value()) {
} else {
}
// add stuff to one big pw<d2<sbasis> > and then outside the loop convert to path?
// No: this way, the separate result paths are kept separate which might come in handy some time!
}
tAclean += incrementA;
tBclean += incrementB;
}
}
return path_out;
} else {
return path_in;
}
}
void
{
if (!SP_IS_PATH(item)) return;
using namespace Geom;
// set the stroke path to run horizontally in the middle of the bounding box of the original path
// calculate bounding box: (isn't there a simpler way?)
std::vector<Geom::Path> temppath = sp_svg_read_pathv( item->getRepr()->attribute("inkscape:original-d"));
}
} else {
// bounding box is too small to make decent path. set to default default. :-)
}
} else {
// bounding box is non-existent. set to default default. :-)
}
}
/** /todo check whether this special case is necessary. It seems to "bug" editing behavior:
* scaling an object with transforms preserved behaves differently from scaling with
* transforms optimized (difference caused by this special method).
* special casing is probably needed, because rotation should not be propagated to the strokepath.
*/
void
{
// only take translations into account
if (postmul.isTranslation()) {
} else if (!scale_y_rel.get_value()) {
// this basically means that for this transformation, the result should be the same as normal scaling the result path
// don't know how to do this yet.
// Geom::Affine new_postmul;
//new_postmul.setIdentity();
// new_postmul.setTranslation(postmul.translation());
// Effect::transform_multiply(new_postmul, set);
}
}
} //namespace LivePathEffect
} /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :