mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Add example to Item#contains(point) docs.
This commit is contained in:
parent
daf8d0f881
commit
a5997dcc24
2 changed files with 23 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue