X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flivarot%2FPathCutting.cpp;h=276c9b260f4796b6a0ec8e9642e6a3153fdb36e9;hb=bee3b1cad515d16fd4fe704ec5ee0dfe3510f802;hp=59de29676f21a6280e99d5410b440739b6ec4a5b;hpb=2717303e39af1fe525a83dc8e8e81bea8d5459eb;p=inkscape.git diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 59de29676..276c9b260 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -991,9 +991,15 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos) const double nearestY = (localPos[NR::X] * gradient + localPos[NR::Y] - intersection * gradient) / (gradient * gradient + 1.0); t = (nearestY - p1[NR::Y]) / (p2[NR::Y] - p1[NR::Y]); - if (t <= 0.0) thisRangeSquared = square(p1[NR::X] - localPos[NR::X]) + square(p1[NR::Y] - localPos[NR::Y]); - else if (t >= 1.0) thisRangeSquared = square(p2[NR::X] - localPos[NR::X]) + square(p2[NR::Y] - localPos[NR::Y]); - else thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]); + if (t <= 0.0) { + thisRangeSquared = square(p1[NR::X] - localPos[NR::X]) + square(p1[NR::Y] - localPos[NR::Y]); + t = 0.0; + } else if (t >= 1.0) { + thisRangeSquared = square(p2[NR::X] - localPos[NR::X]) + square(p2[NR::Y] - localPos[NR::Y]); + t = 1.0; + } else { + thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]); + } } if (thisRangeSquared < bestRangeSquared) { @@ -1008,10 +1014,11 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos) const result.t = 0.0; } else { result.piece = pts[bestSeg].piece; - if (result.piece == pts[bestSeg - 1].piece) + if (result.piece == pts[bestSeg - 1].piece) { result.t = pts[bestSeg - 1].t * (1.0 - bestT) + pts[bestSeg].t * bestT; - else + } else { result.t = pts[bestSeg].t * bestT; + } } return result; }