lpe-sketch.cpp revision b6722d32ca4d7edaad25d0708075bf1c6979997e
#define INKSCAPE_LPE_SKETCH_CPP
/** \file
* LPE <sketch> implementation
*/
/*
* 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-sketch.h"
#include <libnr/n-art-bpath.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(_("Nb of iterations"), _("Draw that many approximating strokes sequences."), "nbiter_approxstrokes", &wr, this, 5),
strokelength(_("Max stroke length"),
strokelength_rdm(_("Stroke length variation"),
_("Random variation of stroke length (relative to max. length)."), "strokelength_rdm", &wr, this, .3),
strokeoverlap(_("Max. overlap"),
_("How much successive strokes should overlap (relative to max. length)."), "strokeoverlap", &wr, this, .3),
strokeoverlap_rdm(_("Overlap variation"),
ends_tolerance(_("Max. ends tolerance"),
_("Max. distance between original and approximated paths ends (relative to max. length)."), "ends_tolerance", &wr, this, .1),
parallel_offset(_("Parallel offset"),
tremble_size(_("Max. tremble"),
tremble_frequency(_("Tremble frequency"),
nbtangents(_("Nb of construction Lines"),
tgtscale(_("Scale"),
_("Scale factor relating curvature and length of construction lines(try 5*avarage offset) )"), "tgtscale", &wr, this, 10.0),
tgtlength(_("Max. length"), _("Max. length of construction lines."), "tgtlength", &wr, this, 100.0),
tgtlength_rdm(_("Length variation"), _("Random variation of construction lines length."), "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;
}
*/
//TODO: does this already exist in 2Geom? if not, move this there...
{
using namespace Geom;
unsigned piece_start = 0;
for (unsigned j = piece_start; j<i+1; j++){
}
piece_start = i+1;
}
}
return ret;
}
//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.
//init random parameters.
// 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;
}
/* ######################## */
} //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 :