From 7f68dafb5c6de511b35f369dfa524a7e24210a78 Mon Sep 17 00:00:00 2001 From: Eric Rowell Date: Fri, 23 Nov 2012 23:55:20 -0800 Subject: [PATCH] fixed up Image hit draw func --- src/shapes/Image.js | 18 ++++++++++++------ tests/js/unit/nodeTests.js | 1 + tests/js/unit/shapes/lineTests.js | 2 +- tests/js/unit/shapes/pathTests.js | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/shapes/Image.js b/src/shapes/Image.js index b2217ac2..f6cb82fe 100644 --- a/src/shapes/Image.js +++ b/src/shapes/Image.js @@ -21,7 +21,7 @@ Kinetic.Image.prototype = { // call super constructor Kinetic.Shape.call(this, config); - this._setDrawFuncs(); + this._setDrawFuncs(); var that = this; this.on('imageChange', function(evt) { @@ -56,13 +56,19 @@ Kinetic.Image.prototype = { drawHitFunc: function(context) { var width = this.getWidth(), height = this.getHeight(), imageBuffer = this.imageBuffer, appliedShadow = false; - context.beginPath(); - context.rect(0, 0, width, height); - context.closePath(); - this.fillStroke(context); - if(imageBuffer) { this.drawImage(context, this.imageBuffer, 0, 0, width, height); + + context.beginPath(); + context.rect(0, 0, width, height); + context.closePath(); + this.stroke(context); + } + else { + context.beginPath(); + context.rect(0, 0, width, height); + context.closePath(); + this.fillStroke(context); } }, /** diff --git a/tests/js/unit/nodeTests.js b/tests/js/unit/nodeTests.js index 8d4d58e1..9d65478e 100644 --- a/tests/js/unit/nodeTests.js +++ b/tests/js/unit/nodeTests.js @@ -771,6 +771,7 @@ Test.Modules.NODE = { cachedShape.createImageBuffer(function() { + console.log(111) layer.draw(); //console.log(layer.toDataURL()); warn(dataUrls['regular and cahced polygon'] === layer.toDataURL(), 'regular and cached polygon layer data url is incorrect'); diff --git a/tests/js/unit/shapes/lineTests.js b/tests/js/unit/shapes/lineTests.js index 4f9b262c..3c0035d6 100644 --- a/tests/js/unit/shapes/lineTests.js +++ b/tests/js/unit/shapes/lineTests.js @@ -85,7 +85,7 @@ Test.Modules.LINE = { blur: 10, offset: [20, 20] }, - opacity: 0.2 + //opacity: 0.2 }); layer.add(line); diff --git a/tests/js/unit/shapes/pathTests.js b/tests/js/unit/shapes/pathTests.js index 8f50e207..14e8ca7c 100644 --- a/tests/js/unit/shapes/pathTests.js +++ b/tests/js/unit/shapes/pathTests.js @@ -392,7 +392,7 @@ Test.Modules.PATH = { layer.add(group); stage.add(layer); - //document.body.appendChild(layer.bufferCanvas.element) + showHit(layer); }, 'Able to determine point on line some distance from another point on line': function(containerId) {