Add example to Item#contains(point) docs.

This commit is contained in:
Jonathan Puckey 2013-04-21 13:56:29 +02:00
parent daf8d0f881
commit a5997dcc24
2 changed files with 23 additions and 3 deletions

View file

@ -1276,11 +1276,32 @@ var Item = this.Item = Base.extend(Callback, {
return raster;
},
// DOCS: Document Item#contains(point)
/**
* Checks wether the item's geometry contains the given point in local
* coordinates.
*
*
* @example {@paperscript} // Click within and outside the star below
* // Create a star shaped path:
* var path = new Path.Star({
* center: [50, 50],
* points: 12,
* radius1: 20,
* radius2: 40,
* fillColor: 'black'
* });
*
* // Whenever the user presses the mouse:
* function onMouseDown(event) {
* // If the position of the mouse is within the path,
* // set its fill color to red, otherwise set it to
* // black:
* if (path.contains(event.point)) {
* path.fillColor = 'red';
* } else {
* path.fillColor = 'black';
* }
* }
*
* @param {Point} point The point to check in local coordinates
*/
contains: function(point) {

View file

@ -1604,7 +1604,6 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
&& this._parent._style.getFillColor());
},
// DOCS: Document Path#contains()
contains: function(point) {
point = Point.read(arguments);
// If the path is not closed, we should not bail out in case it has a