From: buliabyak Date: Sat, 12 Jan 2008 03:49:27 +0000 (+0000) Subject: fix vector, power, and fidelity for paths in transformed groups, also normalize fidel... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3fd5a0570ffa0079069425ce5dff21fe714afa1d;p=inkscape.git fix vector, power, and fidelity for paths in transformed groups, also normalize fidelity for zoom level (still not ideal for very small paths at 256x zoom, I suspect livarot just lacks precision) --- diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index ac59d0544..12b8d8491 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -524,20 +524,13 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in int -Shape::MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc) +Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc) { Reset (0, 0); MakeBackData(a->_has_back_data); bool done_something = false; - double power; - if (mode == tweak_mode_push) { - power = NR::L2(vector); - } else { - power = dec; - } - if (power == 0) { _pts = a->_pts; @@ -604,10 +597,6 @@ Shape::MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, b int stNo, enNo; ptP = a->getPoint(a->getEdge(i).st).x; - if (mode == tweak_mode_push) { - power = 1; - } - NR::Point to_center = ptP * (*i2doc) - c; NR::Point to_center_normalized = (1/NR::L2(to_center)) * to_center; @@ -642,14 +631,19 @@ Shape::MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, b if (this_power != 0) done_something = true; + double scaler = 1 / (*i2doc).expansion(); + NR::Point this_vec(0,0); if (mode == tweak_mode_push) { - this_vec = this_power * vector; + NR::Matrix tovec (*i2doc); + tovec[4] = tovec[5] = 0; + tovec = tovec.inverse(); + this_vec = this_power * (vector * tovec) ; } else if (mode == tweak_mode_repel) { - this_vec = this_power * to_center_normalized; + this_vec = this_power * scaler * to_center_normalized; } else if (mode == tweak_mode_roughen) { double angle = g_random_double_range(0, 2*M_PI); - this_vec = g_random_double_range(0, 1) * this_power * NR::Point(sin(angle), cos(angle)); + this_vec = g_random_double_range(0, 1) * this_power * scaler * NR::Point(sin(angle), cos(angle)); } int usePathID=-1; @@ -675,12 +669,12 @@ Shape::MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, b a->swsData[stB].enPt = stNo; } else { if (power > 0) { - Path::DoRightJoin (this, this_power, join, ptP, stD, seD, miter, stL, seL, + Path::DoRightJoin (this, this_power * scaler, join, ptP, stD, seD, miter, stL, seL, stNo, enNo,usePathID,usePieceID,useT); a->swsData[i].stPt = enNo; a->swsData[stB].enPt = stNo; } else { - Path::DoLeftJoin (this, -this_power, join, ptP, stD, seD, miter, stL, seL, + Path::DoLeftJoin (this, -this_power * scaler, join, ptP, stD, seD, miter, stL, seL, stNo, enNo,usePathID,usePieceID,useT); a->swsData[i].stPt = enNo; a->swsData[stB].enPt = stNo; diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 736ebf2eb..a70ae49d3 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -390,8 +390,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi Shape *theShape = new Shape; Shape *theRes = new Shape; + NR::Matrix i2doc(sp_item_i2doc_affine(item)); - orig->ConvertWithBackData(0.08 - (0.07 * fidelity)); // default 0.059 + orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.expansion()); // default 0.059 orig->Fill(theShape, 0); SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style"); @@ -413,7 +414,6 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi vector = 1/NR::L2(vector) * vector; bool did_this = false; - NR::Matrix i2doc(sp_item_i2doc_affine(item)); if (mode == TWEAK_MODE_SHRINK || mode == TWEAK_MODE_GROW) { if (theShape->MakeTweak(tweak_mode_grow, theRes, mode == TWEAK_MODE_GROW? force : -force, @@ -428,7 +428,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi did_this = true; } else if (mode == TWEAK_MODE_PUSH) { if (theShape->MakeTweak(tweak_mode_push, theRes, - 0, + 1.0, join_straight, 4.0, true, p, force*2*vector, radius, &i2doc) == 0) did_this = true; @@ -447,10 +447,10 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi res->Reset(); theRes->ConvertToForme(res); - double th_max = 0.6 - 0.59*sqrt(fidelity); + double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.expansion(); double threshold = MAX(th_max, th_max*force); res->ConvertEvenLines(threshold); - res->Simplify(threshold); + res->Simplify(threshold / (SP_ACTIVE_DESKTOP->current_zoom())); if (newrepr) { // converting to path, need to replace the repr bool is_selected = selection->includes(item);