summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-patternalongpath.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-12-08 13:18:15 +0000
committerjabiertxof <jabier.arraiza@marker.es>2015-12-08 13:18:15 +0000
commit5ffdf79a6ed7d33ca03d7da3d78cf75389486477 (patch)
tree56c5695b2c6258300d6cf9981cd7d0f0d5fc10c2 /src/live_effects/lpe-patternalongpath.cpp
parentmerge lp:~inkscape.dev/inkscape/bend_and_pattern_along_path_width_modified_by... (diff)
downloadinkscape-5ffdf79a6ed7d33ca03d7da3d78cf75389486477.tar.gz
inkscape-5ffdf79a6ed7d33ca03d7da3d78cf75389486477.zip
add negative values to bend and pattern along path whith knot
(bzr r14516)
Diffstat (limited to 'src/live_effects/lpe-patternalongpath.cpp')
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index ed377e7f9..706091be9 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -291,7 +291,22 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin
if (sp_shape) {
Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path();
Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0));
- lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0));
+ Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0));
+ Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
+ Geom::Ray ray(ptA, B);
+ if (cubic) {
+ ray.setPoints(ptA, (*cubic)[1]);
+ }
+ ray.setAngle(ray.angle() + Geom::deg_to_rad(90));
+ Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse();
+ Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos);
+ if(nearest_to_ray == 0){
+ lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ } else {
+ lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
+ }
+
}
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
@@ -310,10 +325,10 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const
Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve);
Geom::Ray ray(ptA, B);
if (cubic) {
- ray.setPoints((*cubic)[1], ptA);
+ ray.setPoints(ptA, (*cubic)[1]);
}
- Geom::Angle first_curve_angle = ray.transformed(Geom::Rotate(Geom::deg_to_rad(90))).angle();
- Geom::Point result_point = Geom::Point::polar(first_curve_angle, (lpe->original_height * lpe->prop_scale)/2.0) + ptA;
+ ray.setAngle(ray.angle() + Geom::deg_to_rad(90));
+ Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA;
pap_helper_path.clear();
Geom::Path hp(result_point);