fix #93 readded layer isListening and isVisible logic

This commit is contained in:
ericdrowell 2012-10-03 00:04:56 -07:00
parent 0eff286243
commit c6237b59e6
3 changed files with 43 additions and 39 deletions

38
dist/kinetic-core.js vendored
View File

@ -3,7 +3,7 @@
* http://www.kineticjs.com/ * http://www.kineticjs.com/
* Copyright 2012, Eric Rowell * Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses. * Licensed under the MIT or GPL Version 2 licenses.
* Date: Oct 02 2012 * Date: Oct 03 2012
* *
* Copyright (C) 2011 - 2012 by Eric Rowell * Copyright (C) 2011 - 2012 by Eric Rowell
* *
@ -2994,21 +2994,23 @@ Kinetic.Stage.prototype = {
*/ */
for(var n = layers.length - 1; n >= 0; n--) { for(var n = layers.length - 1; n >= 0; n--) {
var layer = layers[n]; var layer = layers[n];
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data; if(layer.isVisible() && layer.isListening()) {
// this indicates that a buffer pixel may have been found var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
if(p[3] === 255) { // this indicates that a buffer pixel may have been found
var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]); if(p[3] === 255) {
shape = Kinetic.Global.shapes[colorKey]; var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]);
return { shape = Kinetic.Global.shapes[colorKey];
shape: shape, return {
pixel: p shape: shape,
}; pixel: p
} };
// if no shape mapped to that pixel, return pixel array }
else if(p[0] > 0 || p[1] > 0 || p[2] > 0 || p[3] > 0) { // if no shape mapped to that pixel, return pixel array
return { else if(p[0] > 0 || p[1] > 0 || p[2] > 0 || p[3] > 0) {
pixel: p return {
}; pixel: p
};
}
} }
} }
@ -3039,14 +3041,14 @@ Kinetic.Stage.prototype = {
* @param {Layer} layer * @param {Layer} layer
*/ */
add: function(layer) { add: function(layer) {
Kinetic.Container.prototype.add.call(this, layer); Kinetic.Container.prototype.add.call(this, layer);
layer.canvas.setSize(this.attrs.width, this.attrs.height); layer.canvas.setSize(this.attrs.width, this.attrs.height);
layer.bufferCanvas.setSize(this.attrs.width, this.attrs.height); layer.bufferCanvas.setSize(this.attrs.width, this.attrs.height);
// draw layer and append canvas to container // draw layer and append canvas to container
layer.draw(); layer.draw();
this.content.appendChild(layer.canvas.element); this.content.appendChild(layer.canvas.element);
// chainable // chainable
return this; return this;
}, },

File diff suppressed because one or more lines are too long

View File

@ -368,21 +368,23 @@ Kinetic.Stage.prototype = {
*/ */
for(var n = layers.length - 1; n >= 0; n--) { for(var n = layers.length - 1; n >= 0; n--) {
var layer = layers[n]; var layer = layers[n];
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data; if(layer.isVisible() && layer.isListening()) {
// this indicates that a buffer pixel may have been found var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
if(p[3] === 255) { // this indicates that a buffer pixel may have been found
var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]); if(p[3] === 255) {
shape = Kinetic.Global.shapes[colorKey]; var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]);
return { shape = Kinetic.Global.shapes[colorKey];
shape: shape, return {
pixel: p shape: shape,
}; pixel: p
} };
// if no shape mapped to that pixel, return pixel array }
else if(p[0] > 0 || p[1] > 0 || p[2] > 0 || p[3] > 0) { // if no shape mapped to that pixel, return pixel array
return { else if(p[0] > 0 || p[1] > 0 || p[2] > 0 || p[3] > 0) {
pixel: p return {
}; pixel: p
};
}
} }
} }
@ -413,14 +415,14 @@ Kinetic.Stage.prototype = {
* @param {Layer} layer * @param {Layer} layer
*/ */
add: function(layer) { add: function(layer) {
Kinetic.Container.prototype.add.call(this, layer); Kinetic.Container.prototype.add.call(this, layer);
layer.canvas.setSize(this.attrs.width, this.attrs.height); layer.canvas.setSize(this.attrs.width, this.attrs.height);
layer.bufferCanvas.setSize(this.attrs.width, this.attrs.height); layer.bufferCanvas.setSize(this.attrs.width, this.attrs.height);
// draw layer and append canvas to container // draw layer and append canvas to container
layer.draw(); layer.draw();
this.content.appendChild(layer.canvas.element); this.content.appendChild(layer.canvas.element);
// chainable // chainable
return this; return this;
}, },