mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Provide point of hit handles and segments too in HitResult.
This commit is contained in:
parent
e813ffd102
commit
af9df0e1b8
2 changed files with 8 additions and 4 deletions
|
@ -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
|
* @property
|
||||||
* @name HitResult#point
|
* @name HitResult#point
|
||||||
|
|
|
@ -1240,10 +1240,13 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
||||||
segment._transformCoordinates(matrix, coords);
|
segment._transformCoordinates(matrix, coords);
|
||||||
for (var j = ends || options.segments ? 0 : 2,
|
for (var j = ends || options.segments ? 0 : 2,
|
||||||
m = !ends && options.handles ? 6 : 2; j < m; j += 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'
|
return new HitResult(j == 0 ? 'segment'
|
||||||
: 'handle-' + (j == 2 ? 'in' : 'out'),
|
: 'handle-' + (j == 2 ? 'in' : 'out'), that, {
|
||||||
that, { segment: segment });
|
segment: segment,
|
||||||
|
point: Point.create(coords[j], coords[j + 1])
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.ends && !options.segments && !this._closed) {
|
if (options.ends && !options.segments && !this._closed) {
|
||||||
|
|
Loading…
Reference in a new issue