lpe-sketch.cpp revision b12c58eb378e0b212277c61471f971e2a97c6156
/** @file
* @brief LPE sketch effect implementation
*/
/* Authors:
* Jean-Francois Barraud <jf.barraud@gmail.com>
* Johan Engelen <j.b.c.engelen@utwente.nl>
*
* Copyright (C) 2007 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-sketch.h"
// You might need to include other 2geom files. You can add them here:
namespace Inkscape {
namespace LivePathEffect {
// initialise your parameters here:
//testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)),
nbiter_approxstrokes(_("Strokes"), _("Draw that many approximating strokes"), "nbiter_approxstrokes", &wr, this, 5),
strokelength(_("Max stroke length"),
strokelength_rdm(_("Stroke length variation"),
_("Random variation of stroke length (relative to maximum length)"), "strokelength_rdm", &wr, this, .3),
strokeoverlap(_("Max. overlap"),
_("How much successive strokes should overlap (relative to maximum length)"), "strokeoverlap", &wr, this, .3),
strokeoverlap_rdm(_("Overlap variation"),
_("Random variation of overlap (relative to maximum overlap)"), "strokeoverlap_rdm", &wr, this, .3),
ends_tolerance(_("Max. end tolerance"),
_("Maximum distance between ends of original and approximating paths (relative to maximum length)"), "ends_tolerance", &wr, this, .1),
parallel_offset(_("Parallel offset"),
tremble_size(_("Max. tremble"),
tremble_frequency(_("Tremble frequency"),
_("Average number of tremble periods in an approximating stroke"), "tremble_frequency", &wr, this, 1.),
nbtangents(_("Construction lines"),
tgtscale(_("Scale"),
_("Scale factor relating curvature and length of construction lines (try 5*offset)"), "tgtscale", &wr, this, 10.0),
tgtlength(_("Max. length"), _("Maximum length of construction lines"), "tgtlength", &wr, this, 100.0),
tgtlength_rdm(_("Length variation"), _("Random variation of the length of construction lines"), "tgtlength_rdm", &wr, this, .3)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
//Add some comment in the UI: *warning* the precise output of this effect might change in future releases!
//convert to path if you want to keep exact output unchanged in future releases...
//registerParameter( dynamic_cast<Parameter *>(&testpointA) );
}
{
}
/*
Geom::Piecewise<Geom::D2<Geom::SBasis> >
addLinearEnds (Geom::Piecewise<Geom::D2<Geom::SBasis> > & m){
using namespace Geom;
Piecewise<D2<SBasis> > output;
Piecewise<D2<SBasis> > start;
Piecewise<D2<SBasis> > end;
double x,y,vx,vy;
x = m.segs.front()[0].at0();
y = m.segs.front()[1].at0();
start = Piecewise<D2<SBasis> >(D2<SBasis>(Linear (x-vx,x),Linear (y-vy,y)));
start.offsetDomain(m.cuts.front()-1.);
x = m.segs.back()[0].at1();
y = m.segs.back()[1].at1();
end = Piecewise<D2<SBasis> >(D2<SBasis>(Linear (x,x+vx),Linear (y,y+vy)));
//end.offsetDomain(m.cuts.back());
output = start;
output.concat(m);
output.concat(end);
return output;
}
*/
//This returns a random perturbation. Notice the domain is [s0,s0+first multiple of period>s1]...
using namespace Geom;
//global offset for this stroke.
//start point A
}
//compute howmany deg 3 sbasis to concat according to frequency.
for (unsigned i=0; i<count; i++){
}
A = B;
}
return res;
}
// Main effect body...
{
using namespace Geom;
//If the input path is empty, do nothing.
//Note: this happens when duplicating a 3d box... dunno why.
// some variables for futur use (for construction lines; compute arclength only once...)
// notations will be : t = path time, s = distance from start along the path.
double total_length = 0;
//TODO: split Construction Lines/Approximated Strokes into two separate effects?
//----- Approximated Strokes.
//work separately on each component.
//TODO: better check this on the Geom::Path.
if (closed){
}
for (unsigned i = 0; i<nbiter_approxstrokes; i++){
//Basic steps:
//- Choose a rdm seg [s0,s1], find coresponding [t0,t1],
//- Pick a rdm perturbation delta(s), collect 'piece(t)+delta(s(t))' over [t0,t1] into output.
// pick a point where to start the stroke (s0 = dist from start).
double s0_initial = s0;
bool done = false;// was the end of the component reached?
while (!done){
// if the start point is already too far... do nothing. (this should not happen!)
// pick a new end point (s1 = s0 + strokelength).
// don't let it go beyond the end of the orgiginal path.
done = true;
//!!the root solver might miss s1==piece_total_length...
}
done = true;
}
}
//pick a rdm perturbation, and collect the perturbed piece into output.
//step points: s0 = s1 - overlap.
//TODO: make sure this has to end?
}
}
}
//----- Construction lines.
//TODO: choose places according to curvature?.
//at this point we should have:
//pathlength = arcLengthSb(pwd2_in,.1);
//total_length = pathlength.segs.back().at1()-pathlength.segs.front().at0();
for (unsigned i=0; i<nbtangents; i++){
// pick a point where to draw a tangent (s = dist from start along path).
//Compute tgt length according to curvature (not exceeding tgtlength) so that
// dist to origninal curve ~ 4 * (parallel_offset+tremble_size).
//TODO: put this 4 as a parameter in the UI...
//TODO: what if with v=0?
l=(r<l)?r:l;
//collect the tgt segment into output.
}
}
return output;
}
void
{
//init random parameters.
}
/* ######################## */
} //namespace LivePathEffect (setq default-directory "c:/Documents And Settings/jf/Mes Documents/InkscapeSVN")
} /* 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:encoding=utf-8:textwidth=99 :