mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-29 15:19:20 -04:00
Document HitResult, Item#hitTest(point, options) and Project#hitTest(point, options).
This commit is contained in:
parent
e73a2df6b2
commit
e0650cae73
3 changed files with 128 additions and 1 deletions
src/project
|
@ -181,6 +181,40 @@ var Project = this.Project = Base.extend(/** @lends Project# */{
|
|||
this._selectedItems[i].setSelected(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* Perform a hit test on the items contained within the project at the
|
||||
* location of the specified point.
|
||||
*
|
||||
* The optional options object allows you to control the specifics of the
|
||||
* hit test and may contain a combination of the following values:
|
||||
* <b>tolerance:</b> {@code Number} - The tolerance of the hit test in
|
||||
* points.
|
||||
* <b>type:</b> Only hit test again a certain item
|
||||
* type: {@link PathItem}, {@link Raster}, {@link TextItem}, etc.
|
||||
* <b>fill:</b> {@code Boolean} - Hit test the fill of items.
|
||||
* <b>stroke:</b> {@code Boolean} - Hit test the curves of path items,
|
||||
* taking into account stroke width.
|
||||
* <b>segment:</b> {@code Boolean} - Hit test for {@link Segment#point} of
|
||||
* {@link Path} items.
|
||||
* <b>handles:</b> {@code Boolean} - Hit test for the handles
|
||||
* ({@link Segment#handleIn} / {@link Segment#handleOut}) of path segments.
|
||||
* <b>ends:</b> {@code Boolean} - Only hit test for the first or last
|
||||
* segment points of open path items.
|
||||
* <b>bounds:</b> {@code Boolean} - Hit test the corners and side-centers
|
||||
* of the bounding rectangle of items ({@link Item#bounds}).
|
||||
* <b>center:</b> {@code Boolean} - Hit test the {@link Rectangle#center}
|
||||
* of the bounding rectangle of items ({@link Item#bounds}).
|
||||
* <b>guide:</b> {@code Boolean} - Hit test items that have
|
||||
* {@link Item#guide} set to {@code true}.
|
||||
* <b>selected:</b> {@code Boolean} - Only hit selected items.
|
||||
*
|
||||
* @param {Point} point The point where the hit test should be performed
|
||||
* @param {Object} [options={ fill: true, stroke: true, segments: true,
|
||||
* tolerance: true }]
|
||||
* @return {HitResult|null} A hit result object that contains more
|
||||
* information about what exactly was hit or {@code null} if nothing was
|
||||
* hit.
|
||||
*/
|
||||
hitTest: function(point, options) {
|
||||
options = HitResult.getOptions(point, options);
|
||||
point = options.point;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue