Merge remote-tracking branch 'origin/master'

This commit is contained in:
Jürg Lehni 2011-08-01 08:56:07 +01:00
commit 6086165d1a
4 changed files with 129 additions and 2 deletions

@ -1 +1 @@
Subproject commit 678f1ac39d6f78dda0bee723d51d1e3a286e5fd2
Subproject commit 17d8366c4f91ce9fa98e948755a63590a7871378

View file

@ -17,7 +17,8 @@
/**
* @name HitResult
*
* @class
* @class A HitResult object contains information about the results of a hit
* test.
*
* @extends CurveLocation
*/
@ -34,6 +35,61 @@ HitResult = Base.extend(/** @lends HitResult# */{
}
},
/**
* Describes the type of the hit result. For example, if you hit a segment
* point, the type would be 'segment'.
*
* @property
* @name HitResult#type
* @type String('segment', 'handle-in', 'handle-out', 'stroke', 'fill',
* 'bounds', 'center')
*/
/**
* If the HitResult has a {@link HitResult#type} of 'bounds', this property
* describes which corner of the bounding rectangle was hit.
*
* @property
* @name HitResult#name
* @type String('top-left', 'top-right', 'bottom-left', 'bottom-right',
* 'left-center', 'top-center', 'right-center', 'bottom-center')
*/
/**
* The item that was hit.
*
* @property
* @name HitResult#item
* @type Item
*/
/**
* If the HitResult has a type of 'stroke', this property gives more
* information about the exact position that was hit on the path.
*
* @property
* @name HitResult#location
* @type CurveLocation
*/
/**
* If the HitResult has a type of 'stroke', 'segment', 'handle-in' or
* 'handle-out', this property refers to the Segment that was hit or that
* is closest to the hitResult.location on the curve.
*
* @property
* @name HitResult#segment
* @type Segment
*/
/**
* The hit point.
*
* @property
* @name HitResult#point
* @type Point
*/
statics: {
/**
* Merges default options into options hash for #hitTest() calls, and

View file

@ -682,6 +682,43 @@ var Item = this.Item = Base.extend(/** @lends Item# */{
return raster;
},
/**
* Perform a hit test on the item (and its children, if it is a
* {@link Group} or {@link Layer}) 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: 2 }]
* @param {Matrix} [matrix]
* @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, matrix) {
options = HitResult.getOptions(point, options);
point = options.point;

View file

@ -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;