summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 67c2385)
raw | patch | inline | side by side (parent: 67c2385)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 12 Jan 2008 03:49:27 +0000 (03:49 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 12 Jan 2008 03:49:27 +0000 (03:49 +0000) |
src/livarot/ShapeMisc.cpp | patch | blob | history | |
src/tweak-context.cpp | patch | blob | history |
index ac59d0544f1eb45505756b85a9e94b6f02bd1707..12b8d84910226ea145069b48e6396e097e5629a6 100644 (file)
@@ -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 736ebf2eb7e5f7764f6123198dcb38eecbdddd51..a70ae49d325701a3170a173dafbd550e5a8e80d8 100644 (file)
--- 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);