summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: da58597)
raw | patch | inline | side by side (parent: da58597)
author | joncruz <joncruz@users.sourceforge.net> | |
Tue, 7 Apr 2009 06:42:08 +0000 (06:42 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Tue, 7 Apr 2009 06:42:08 +0000 (06:42 +0000) |
index 4cf3e35e67123254141b69dcb8a4ccfc89c353ce..49073fd6485f18365aeafb67348290bf94f5078d 100644 (file)
@@ -222,7 +222,7 @@ Piecewise<D2<SBasis> > bend(Piecewise<D2<SBasis> > const &f, Piecewise<SBasis> b
//--------------------------------------------------------
LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- direction(_("Hatches width and dir"), _("Defines hatches frequency and direction"), "direction", &wr, this, Geom::Point(50,0)),
+ hatch_dist(0),
dist_rdm(_("Frequency randomness"), _("Variation of dist between hatches, in %."), "dist_rdm", &wr, this, 75),
growth(_("Growth"), _("Growth of distance between hatches."), "growth", &wr, this, 0.),
//FIXME: top/bottom names are inverted in the UI/svg and in the code!!
scale_tb(_("1st side, out"), _("Set smoothness/sharpness of path when leaving a 'bottom' halfturn. 0=sharp, 1=default"), "scale_bb", &wr, this, 1.),
scale_bf(_("2nd side, in "), _("Set smoothness/sharpness of path when reaching a 'top' halfturn. 0=sharp, 1=default"), "scale_tf", &wr, this, 1.),
scale_bb(_("2nd side, out"), _("Set smoothness/sharpness of path when leaving a 'top' halfturn. 0=sharp, 1=default"), "scale_tb", &wr, this, 1.),
- top_smth_variation(_("variance: 1st side"), _("Randomness of 'bottom' halfturns smoothness"), "top_smth_variation", &wr, this, 0),
- bot_smth_variation(_("2nd side"), _("Randomness of 'top' halfturns smoothness"), "bottom_smth_variation", &wr, this, 0),
-//
top_edge_variation(_("Magnitude jitter: 1st side"), _("Randomly moves 'bottom' halfsturns to produce magnitude variations."), "bottom_edge_variation", &wr, this, 0),
bot_edge_variation(_("2nd side"), _("Randomly moves 'top' halfsturns to produce magnitude variations."), "top_edge_variation", &wr, this, 0),
top_tgt_variation(_("Parallelism jitter: 1st side"), _("Add direction randomness by moving 'bottom' halfsturns tangentially to the boundary."), "bottom_tgt_variation", &wr, this, 0),
bot_tgt_variation(_("2nd side"), _("Add direction randomness by randomly moving 'top' halfsturns tangentially to the boundary."), "top_tgt_variation", &wr, this, 0),
-//
- do_bend(_("Bend hatches"), _("Add a global bend to the hatches (slower)"), "do_bend", &wr, this, true),
- //bender(_("Global bending"), _("Relative position to ref point defines global bending direction and amount"), "bender", &wr, this, NULL, Geom::Point(-5,0)),
- bender(_("Global bending"), _("Relative position to ref point defines global bending direction and amount"), "bender", &wr, this, Geom::Point(-5,0)),
+ top_smth_variation(_("variance: 1st side"), _("Randomness of 'bottom' halfturns smoothness"), "top_smth_variation", &wr, this, 0),
+ bot_smth_variation(_("2nd side"), _("Randomness of 'top' halfturns smoothness"), "bottom_smth_variation", &wr, this, 0),
//
fat_output(_("Generate thick/thin path"), _("Simulate a stroke of varrying width"), "fat_output", &wr, this, true),
+ do_bend(_("Bend hatches"), _("Add a global bend to the hatches (slower)"), "do_bend", &wr, this, true),
stroke_width_top(_("Thikness: at 1st side"), _("Width at 'bottom' half turns"), "stroke_width_top", &wr, this, 1.),
stroke_width_bot(_("at 2nd side"), _("Width at 'top' halfturns"), "stroke_width_bottom", &wr, this, 1.),
+//
front_thickness(_("from 2nd to 1st side"), _("Width of paths from 'top' to 'bottom' halfturns"), "front_thickness", &wr, this, 1.),
- back_thickness(_("from 1st to 2nd side"), _("Width of paths from 'top' to 'bottom' halfturns"), "back_thickness", &wr, this, .25)
+ back_thickness(_("from 1st to 2nd side"), _("Width of paths from 'top' to 'bottom' halfturns"), "back_thickness", &wr, this, .25),
+
+ direction(_("Hatches width and dir"), _("Defines hatches frequency and direction"), "direction", &wr, this, Geom::Point(50,0)),
+//
+ //bender(_("Global bending"), _("Relative position to ref point defines global bending direction and amount"), "bender", &wr, this, NULL, Geom::Point(-5,0)),
+ bender(_("Global bending"), _("Relative position to ref point defines global bending direction and amount"), "bender", &wr, this, Geom::Point(-5,0))
{
registerParameter( dynamic_cast<Parameter *>(&direction) );
registerParameter( dynamic_cast<Parameter *>(&dist_rdm) );
index 22c758d1035057539c53ddd2931696d74b0ba6eb..2fa96597fd4de21373a100196a56e2c8bc5776d3 100644 (file)
// 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(_("Max stroke length"),
_("Maximum length of approximating strokes"), "strokelength", &wr, this, 100.),
- strokelength_rdm(_("Stroke length variation"),
+ strokelength_rdm(_("Stroke length variation"),
_("Random variation of stroke length (relative to maximum length)"), "strokelength_rdm", &wr, this, .3),
- strokeoverlap(_("Max. overlap"),
+ strokeoverlap(_("Max. overlap"),
_("How much successive strokes should overlap (relative to maximum length)"), "strokeoverlap", &wr, this, .3),
- strokeoverlap_rdm(_("Overlap variation"),
+ strokeoverlap_rdm(_("Overlap variation"),
_("Random variation of overlap (relative to maximum overlap)"), "strokeoverlap_rdm", &wr, this, .3),
- ends_tolerance(_("Max. end tolerance"),
+ 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"),
+ parallel_offset(_("Parallel offset"),
_("Average distance from approximating path to original path"), "parallel_offset", &wr, this, 5.),
- tremble_size(_("Max. tremble"),
+ tremble_size(_("Max. tremble"),
_("Maximum tremble magnitude"), "tremble_size", &wr, this, 5.),
- tremble_frequency(_("Tremble frequency"),
+ tremble_frequency(_("Tremble frequency"),
_("Average number of tremble periods in an approximating stroke"), "tremble_frequency", &wr, this, 1.),
- nbtangents(_("Construction lines"),
+ nbtangents(_("Construction lines"),
_("How many construction lines (tangents) to draw"), "nbtangents", &wr, this, 5),
- tgtscale(_("Scale"),
+ 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)
//This returns a random perturbation. Notice the domain is [s0,s0+first multiple of period>s1]...
-Geom::Piecewise<Geom::D2<Geom::SBasis> >
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPESketch::computePerturbation (double s0, double s1){
using namespace Geom;
Piecewise<D2<SBasis> >res;
-
+
//global offset for this stroke.
double offsetX = parallel_offset-parallel_offset.get_value();
double offsetY = parallel_offset-parallel_offset.get_value();
dA[dim] = 2*tremble_size-tremble_size.get_value();
}
//compute howmany deg 3 sbasis to concat according to frequency.
- unsigned count = unsigned((s1-s0)/strokelength*tremble_frequency)+1;
+ unsigned count = unsigned((s1-s0)/strokelength*tremble_frequency)+1;
for (unsigned i=0; i<count; i++){
D2<SBasis> perturb = D2<SBasis>(SBasis(2, Linear()), SBasis(2, Linear()));
for (unsigned dim=0; dim<2; dim++){
@@ -189,7 +189,7 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
//----- Approximated Strokes.
std::vector<Piecewise<D2<SBasis> > > pieces_in = split_at_discontinuities (pwd2_in);
-
+
//work separately on each component.
for (unsigned pieceidx = 0; pieceidx < pieces_in.size(); pieceidx++){
@@ -198,22 +198,22 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
double piece_total_length = piecelength.segs.back().at1()-piecelength.segs.front().at0();
pathlength.concat(piecelength + total_length);
total_length += piece_total_length;
-
+
//TODO: better check this on the Geom::Path.
- bool closed = piece.segs.front().at0() == piece.segs.back().at1();
- if (closed){
+ bool closed = piece.segs.front().at0() == piece.segs.back().at1();
+ if (closed){
piece.concat(piece);
piecelength.concat(piecelength+piece_total_length);
}
for (unsigned i = 0; i<nbiter_approxstrokes; i++){
- //Basic steps:
- //- Choose a rdm seg [s0,s1], find coresponding [t0,t1],
+ //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 s1=0.,s0 = ends_tolerance*strokelength+0.0001;//the root finder might miss 0.
+ double s1=0.,s0 = ends_tolerance*strokelength+0.0001;//the root finder might miss 0.
double t1, t0;
double s0_initial = s0;
bool done = false;// was the end of the component reached?
@@ -223,10 +223,10 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
if (!closed && s1>piece_total_length - ends_tolerance.get_value()*strokelength) break;
if ( closed && s0>piece_total_length + s0_initial) break;
- std::vector<double> times;
- times = roots(piecelength-s0);
+ std::vector<double> times;
+ times = roots(piecelength-s0);
t0 = times.at(0);//there should be one and only one solution!!
-
+
// pick a new end point (s1 = s0 + strokelength).
s1 = s0 + strokelength*(1-strokelength_rdm);
// don't let it go beyond the end of the orgiginal path.
@@ -242,10 +242,10 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
s1 = 2*piece_total_length - strokeoverlap*(1-strokeoverlap_rdm)*strokelength-0.0001;
}
}
- times = roots(piecelength-s1);
+ times = roots(piecelength-s1);
if (times.size()==0) break;//we should not be there.
t1 = times[0];
-
+
//pick a rdm perturbation, and collect the perturbed piece into output.
Piecewise<D2<SBasis> > pwperturb = computePerturbation(s0-0.01,s1+0.01);
pwperturb = compose(pwperturb,portion(piecelength,t0,t1));
@@ -273,11 +273,11 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
// pick a point where to draw a tangent (s = dist from start along path).
double s = total_length * ( i + tgtlength_rdm ) / (nbtangents+1.);
- std::vector<double> times;
+ std::vector<double> times;
times = roots(pathlength-s);
double t = times.at(0);//there should be one and only one solution!
Point m_t = m(t), v_t = v(t), a_t = a(t);
- //Compute tgt length according to curvature (not exceeding tgtlength) so that
+ //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?
@@ -292,12 +292,12 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
}
output.concat(Piecewise<D2<SBasis> >(tgt));
}
-
+
return output;
}
void
-LPESketch::doBeforeEffect (SPLPEItem *lpeitem)
+LPESketch::doBeforeEffect (SPLPEItem */*lpeitem*/)
{
//init random parameters.
parallel_offset.resetRandomizer();
index f18c4011be1c75cfebfda25cb284ef79768bf984..32fb763d3ca57377aad6eb27d7e5846f95119230 100644 (file)
LPEVonKoch::LPEVonKoch(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- ref_path(_("Reference segment"), _("The reference segment. Defaults to bbox diameter."), "ref_path", &wr, this, "M0,0 L10,0"),
- //refA(_("Ref Start"), _("Left side middle of the reference box"), "refA", &wr, this),
- //refB(_("Ref End"), _("Right side middle of the reference box"), "refB", &wr, this),
+ nbgenerations(_("Nb of generations"), _("Depth of the recursion --- keep low!!"), "nbgenerations", &wr, this, 1),
generator(_("Generating path"), _("Path whose segments define the iterated transforms"), "generator", &wr, this, "M0,0 L30,0 M0,10 L10,10 M 20,10 L30,10"),
similar_only(_("Use uniform transforms only"), _("2 consecutive segments are used to reverse/preserve orientation only (otherwise, they define a general transform)."), "similar_only", &wr, this, false),
- nbgenerations(_("Nb of generations"), _("Depth of the recursion --- keep low!!"), "nbgenerations", &wr, this, 1),
drawall(_("Draw all generations"), _("If unchecked, draw only the last generation"), "drawall", &wr, this, true),
+ //,draw_boxes(_("Display boxes"), _("Display boxes instead of paths only"), "draw_boxes", &wr, this, true)
+ ref_path(_("Reference segment"), _("The reference segment. Defaults to bbox diameter."), "ref_path", &wr, this, "M0,0 L10,0"),
+ //refA(_("Ref Start"), _("Left side middle of the reference box"), "refA", &wr, this),
+ //refB(_("Ref End"), _("Right side middle of the reference box"), "refB", &wr, this),
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
maxComplexity(_("Max complexity"), _("Disable effect if the output is too complex"), "maxComplexity", &wr, this, 1000)
- //,draw_boxes(_("Display boxes"), _("Display boxes instead of paths only"), "draw_boxes", &wr, this, true)
{
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
registerParameter( dynamic_cast<Parameter *>(&ref_path) );
index abe3cee3a9258483b9abec25da9c049389929311..35afe7f5d39ff8eb3f2ef414981d9b48fcf780fc 100644 (file)
VectorParamKnotHolderEntity_Vector(VectorParam *p) : param(p) { }
virtual ~VectorParamKnotHolderEntity_Vector() {}
- virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) {
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) {
Geom::Point const s = p - param->origin;
/// @todo implement angle snapping when holding CTRL
param->setVector(s);