Skip to content

Commit

Permalink
rounding pos components when used with getImageData
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdrowell committed Aug 26, 2012
1 parent 79a1029 commit 89611ae
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
13 changes: 2 additions & 11 deletions dist/kinetic-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions dist/kinetic-core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
9 changes: 0 additions & 9 deletions src/util/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 89611ae

Please sign in to comment.