Provide point of hit handles and segments too in HitResult.

This commit is contained in:
Jürg Lehni 2011-11-11 14:47:03 +01:00
parent e813ffd102
commit af9df0e1b8
2 changed files with 8 additions and 4 deletions

View file

@ -80,7 +80,8 @@ HitResult = Base.extend(/** @lends HitResult# */{
*/
/**
* The hit point.
* Describes the actual coordinates of the segment, handle or bounding box
* corner that was hit.
*
* @property
* @name HitResult#point

View file

@ -1240,10 +1240,13 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
segment._transformCoordinates(matrix, coords);
for (var j = ends || options.segments ? 0 : 2,
m = !ends && options.handles ? 6 : 2; j < m; j += 2) {
if (point.getDistance(coords[j], coords[j + 1]) < tolerance)
if (point.getDistance(coords[j], coords[j + 1]) < tolerance) {
return new HitResult(j == 0 ? 'segment'
: 'handle-' + (j == 2 ? 'in' : 'out'),
that, { segment: segment });
: 'handle-' + (j == 2 ? 'in' : 'out'), that, {
segment: segment,
point: Point.create(coords[j], coords[j + 1])
});
}
}
}
if (options.ends && !options.segments && !this._closed) {