diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-12-08 13:18:15 +0000 |
|---|---|---|
| committer | jabiertxof <jabier.arraiza@marker.es> | 2015-12-08 13:18:15 +0000 |
| commit | 5ffdf79a6ed7d33ca03d7da3d78cf75389486477 (patch) | |
| tree | 56c5695b2c6258300d6cf9981cd7d0f0d5fc10c2 /src | |
| parent | merge lp:~inkscape.dev/inkscape/bend_and_pattern_along_path_width_modified_by... (diff) | |
| download | inkscape-5ffdf79a6ed7d33ca03d7da3d78cf75389486477.tar.gz inkscape-5ffdf79a6ed7d33ca03d7da3d78cf75389486477.zip | |
add negative values to bend and pattern along path whith knot
(bzr r14516)
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-bendpath.cpp | 20 | ||||
| -rw-r--r-- | src/live_effects/lpe-patternalongpath.cpp | 23 |
2 files changed, 36 insertions, 7 deletions
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index 5c20a7f9e..874e23c4c 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -192,7 +192,21 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const& Geom::Point const s = snap_knot_position(p, state); Geom::Path path_in = lpe->bend_path.get_pathvector().pathAt(Geom::PathVectorTime(0, 0, 0.0)); 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); } @@ -211,8 +225,8 @@ KnotHolderEntityWidthBendPath::knot_get() const if (cubic) { 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; bp_helper_path.clear(); Geom::Path hp(result_point); 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); |
