cleaned up intersects logic, and added more docs

This commit is contained in:
Eric Rowell
2012-07-14 18:41:34 -07:00
parent 864938ed33
commit 2629c1237c
4 changed files with 19 additions and 7 deletions

View File

@@ -306,6 +306,7 @@ Kinetic.Shape = Kinetic.Node.extend({
var pos = Kinetic.Type._getXY(Array.prototype.slice.call(arguments));
var stage = this.getStage();
// path detection
if(this.attrs.detectionType === 'path') {
var pathLayer = stage.pathLayer;
var pathLayerContext = pathLayer.getContext();
@@ -314,11 +315,16 @@ Kinetic.Shape = Kinetic.Node.extend({
return pathLayerContext.isPointInPath(pos.x, pos.y);
}
else {
// pixel detection
if(this.imageData) {
var w = stage.attrs.width;
var alpha = this.imageData.data[((w * pos.y) + pos.x) * 4 + 3];
return (!!alpha);
return (alpha);
}
// default
return false;
},
_draw: function(layer) {
if(layer && this.attrs.drawFunc) {