mirror of
https://github.com/konvajs/konva.git
synced 2025-12-26 22:55:44 +08:00
cleaned up intersects logic, and added more docs
This commit is contained in:
10
src/Shape.js
10
src/Shape.js
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user