rounding pos components when used with getImageData

This commit is contained in:
Eric Rowell 2012-08-26 12:23:29 -07:00
parent 79a1029adb
commit 89611aed5f
5 changed files with 6 additions and 24 deletions

13
dist/kinetic-core.js vendored
View File

@ -560,15 +560,6 @@ Kinetic.Canvas.prototype = {
this.setWidth(width);
this.setHeight(height);
},
/**
* strip away all functions that draw pixels onto the bitmap
* @name strip
* @methodOf Kinetic.Canvas.prototype
* @param {CanvasContext} context
*/
strip: function() {
var context = this.context;
},
/**
* toDataURL
*/
@ -3032,7 +3023,7 @@ Kinetic.Stage.prototype = {
*/
for(var n = layers.length - 1; n >= 0; n--) {
var layer = layers[n];
var p = layer.bufferCanvas.context.getImageData(pos.x, pos.y, 1, 1).data;
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
// this indicates that a buffer pixel may have been found
if(p[3] === 255) {
var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]);
@ -4090,7 +4081,7 @@ Kinetic.Shape.prototype = {
var bufferCanvas = stage.bufferCanvas;
bufferCanvas.clear();
this._draw(bufferCanvas);
var p = bufferCanvas.context.getImageData(pos.x, pos.y, 1, 1).data;
var p = bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
return p[3] > 0;
},
__draw: function(canvas) {

File diff suppressed because one or more lines are too long

View File

@ -332,7 +332,7 @@ Kinetic.Shape.prototype = {
var bufferCanvas = stage.bufferCanvas;
bufferCanvas.clear();
this._draw(bufferCanvas);
var p = bufferCanvas.context.getImageData(pos.x, pos.y, 1, 1).data;
var p = bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
return p[3] > 0;
},
__draw: function(canvas) {

View File

@ -364,7 +364,7 @@ Kinetic.Stage.prototype = {
*/
for(var n = layers.length - 1; n >= 0; n--) {
var layer = layers[n];
var p = layer.bufferCanvas.context.getImageData(pos.x, pos.y, 1, 1).data;
var p = layer.bufferCanvas.context.getImageData(Math.round(pos.x), Math.round(pos.y), 1, 1).data;
// this indicates that a buffer pixel may have been found
if(p[3] === 255) {
var colorKey = Kinetic.Type._rgbToHex(p[0], p[1], p[2]);

View File

@ -84,15 +84,6 @@ Kinetic.Canvas.prototype = {
this.setWidth(width);
this.setHeight(height);
},
/**
* strip away all functions that draw pixels onto the bitmap
* @name strip
* @methodOf Kinetic.Canvas.prototype
* @param {CanvasContext} context
*/
strip: function() {
var context = this.context;
},
/**
* toDataURL
*/