diff --git a/Gruntfile.js b/Gruntfile.js index b3d846ee..84a2b604 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -59,18 +59,6 @@ module.exports = function(grunt) { 'tests/js/unit/ddTests.js', 'tests/js/unit/canvasTests.js', - 'tests/js/unit/shapes/rectTests.js', - 'tests/js/unit/shapes/circleTests.js', - 'tests/js/unit/shapes/ellipseTests.js', - 'tests/js/unit/shapes/wedgeTests.js', - 'tests/js/unit/shapes/imageTests.js', - 'tests/js/unit/shapes/polygonTests.js', - 'tests/js/unit/shapes/lineTests.js', - 'tests/js/unit/shapes/splineTests.js', - 'tests/js/unit/shapes/blobTests.js', - 'tests/js/unit/shapes/textTests.js', - 'tests/js/unit/shapes/spriteTests.js', - 'tests/js/unit/plugins/pathTests.js', 'tests/js/unit/plugins/regularPolygonTests.js', 'tests/js/unit/plugins/starTests.js', diff --git a/src/Context.js b/src/Context.js index 54d9c108..3144d048 100644 --- a/src/Context.js +++ b/src/Context.js @@ -16,10 +16,13 @@ 'createLinearGradient', 'createPattern', 'createRadialGradient', + 'drawImage', 'fill', 'fillText', + 'getImageData', 'lineTo', 'moveTo', + 'putImageData', 'rect', 'restore', 'rotate', @@ -60,7 +63,6 @@ */ getTrace: function() { return this.traceArr.join(';'); - }, /** * clear trace if trace is enabled @@ -233,6 +235,16 @@ var a = arguments; return this._context.createRadialGradient(a[0], a[1], a[2], a[3], a[4], a[5]); }, + drawImage: function() { + var a = arguments, + _context = this._context; + if(a.length === 5) { + _context.drawImage(a[0], a[1], a[2], a[3], a[4]); + } + else if(a.length === 9) { + _context.drawImage(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); + } + }, fill: function() { this._context.fill(); }, @@ -240,6 +252,10 @@ var a = arguments; this._context.fillText(a[0], a[1], a[2]); }, + getImageData: function() { + var a = arguments; + return this._context.getImageData(a[0], a[1], a[2], a[3]); + }, lineTo: function() { var a = arguments; this._context.lineTo(a[0], a[1]); @@ -252,6 +268,10 @@ var a = arguments; this._context.rect(a[0], a[1], a[2], a[3]); }, + putImageData: function() { + var a = arguments; + this._context.rect(a[0], a[1], a[2]); + }, restore: function() { this._context.restore(); }, diff --git a/src/shapes/Image.js b/src/shapes/Image.js index b856d86d..0cbcd097 100644 --- a/src/shapes/Image.js +++ b/src/shapes/Image.js @@ -45,7 +45,6 @@ height = this.getHeight(), params, that = this, - _context = context._context, cropX = this.getCropX() || 0, cropY = this.getCropY() || 0, cropWidth = this.getCropWidth(), @@ -66,9 +65,9 @@ image = this.getImage(); } - _context.beginPath(); - _context.rect(0, 0, width, height); - _context.closePath(); + context.beginPath(); + context.rect(0, 0, width, height); + context.closePath(); context.fillStrokeShape(this); if(image) { @@ -83,31 +82,30 @@ if(this.hasShadow()) { context.applyShadow(this, function() { - that._drawImage(_context, params); + context.drawImage.apply(context, params); }); } else { - this._drawImage(_context, params); + context.drawImage.apply(context, params); } } }, drawHitFunc: function(context) { var width = this.getWidth(), height = this.getHeight(), - imageHitRegion = this.imageHitRegion, - _context = context._context; + imageHitRegion = this.imageHitRegion; if(imageHitRegion) { - _context.drawImage(imageHitRegion, 0, 0, width, height); - _context.beginPath(); - _context.rect(0, 0, width, height); - _context.closePath(); + context.drawImage(imageHitRegion, 0, 0, width, height); + context.beginPath(); + context.rect(0, 0, width, height); + context.closePath(); context.stroke(this); } else { - _context.beginPath(); - _context.rect(0, 0, width, height); - _context.closePath(); + context.beginPath(); + context.rect(0, 0, width, height); + context.closePath(); context.fillStrokeShape(this); } }, @@ -117,7 +115,7 @@ width = this.getWidth(), height = this.getHeight(), filter = this.getFilter(), - filterCanvas, _context, imageData; + filterCanvas, context, imageData; if (this.filterCanvas){ filterCanvas = this.filterCanvas; @@ -131,13 +129,13 @@ }); } - _context = filterCanvas.getContext()._context; + context = filterCanvas.getContext(); try { - this._drawImage(_context, [image, 0, 0, filterCanvas.getWidth(), filterCanvas.getHeight()]); - imageData = _context.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight()); + context.drawImage(image, 0, 0, filterCanvas.getWidth(), filterCanvas.getHeight()); + imageData = context.getImageData(0, 0, filterCanvas.getWidth(), filterCanvas.getHeight()); filter.call(this, imageData); - _context.putImageData(imageData, 0, 0); + context.putImageData(imageData, 0, 0); } catch(e) { this.clearFilter(); @@ -170,14 +168,14 @@ width: width, height: height }), - _context = canvas.getContext()._context, + context = canvas.getContext(), image = this.getImage(), imageData, data, rgbColorKey, i, n; - _context.drawImage(image, 0, 0); + context.drawImage(image, 0, 0); try { - imageData = _context.getImageData(0, 0, width, height); + imageData = context.getImageData(0, 0, width, height); data = imageData.data; rgbColorKey = Kinetic.Util._hexToRgb(this.colorKey); @@ -216,14 +214,6 @@ getHeight: function() { var image = this.getImage(); return this.attrs.height || (image ? image.height : 0); - }, - _drawImage: function(_context, a) { - if(a.length === 5) { - _context.drawImage(a[0], a[1], a[2], a[3], a[4]); - } - else if(a.length === 9) { - _context.drawImage(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]); - } } }; Kinetic.Util.extend(Kinetic.Image, Kinetic.Shape); diff --git a/src/shapes/Wedge.js b/src/shapes/Wedge.js index a20941ec..c9dbf00f 100644 --- a/src/shapes/Wedge.js +++ b/src/shapes/Wedge.js @@ -32,12 +32,10 @@ this.className = 'Wedge'; }, drawFunc: function(context) { - var _context = context._context; - - _context.beginPath(); - _context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise()); - _context.lineTo(0, 0); - _context.closePath(); + context.beginPath(); + context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise()); + context.lineTo(0, 0); + context.closePath(); context.fillStrokeShape(this); } }; diff --git a/test/runner.html b/test/runner.html index ee7445d4..9efe8b8a 100644 --- a/test/runner.html +++ b/test/runner.html @@ -52,15 +52,23 @@ kineticContainer.appendChild(title); }); + + - - - - - - - + + + + + + + + + + + + +