diff --git a/src/plugins/Star.js b/src/plugins/Star.js index 62edbc8c..849a37c5 100644 --- a/src/plugins/Star.js +++ b/src/plugins/Star.js @@ -34,21 +34,20 @@ this.setDrawFunc(this._drawFunc); }, _drawFunc: function(context) { - var _context = context._context, - innerRadius = this.attrs.innerRadius, - outerRadius = this.attrs.outerRadius, - numPoints = this.attrs.numPoints; + var innerRadius = this.innerRadius(), + outerRadius = this.outerRadius(), + numPoints = this.numPoints(); - _context.beginPath(); - _context.moveTo(0, 0 - this.attrs.outerRadius); + context.beginPath(); + context.moveTo(0, 0 - outerRadius); for(var n = 1; n < numPoints * 2; n++) { var radius = n % 2 === 0 ? outerRadius : innerRadius; var x = radius * Math.sin(n * Math.PI / numPoints); var y = -1 * radius * Math.cos(n * Math.PI / numPoints); - _context.lineTo(x, y); + context.lineTo(x, y); } - _context.closePath(); + context.closePath(); context.fillStrokeShape(this); } @@ -56,7 +55,7 @@ Kinetic.Util.extend(Kinetic.Star, Kinetic.Shape); // add getters setters - Kinetic.Factory.addGetterSetter(Kinetic.Star, 'numPoints', 0); + Kinetic.Factory.addGetterSetter(Kinetic.Star, 'numPoints', 5); /** * set number of points diff --git a/test/performance/rotate-cached-star.html b/test/performance/rotate-cached-star.html new file mode 100644 index 00000000..b267dfc2 --- /dev/null +++ b/test/performance/rotate-cached-star.html @@ -0,0 +1,64 @@ + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/test/performance/rotate-star.html b/test/performance/rotate-star.html new file mode 100644 index 00000000..ee8a4898 --- /dev/null +++ b/test/performance/rotate-star.html @@ -0,0 +1,57 @@ + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/test/setStats.js b/test/setStats.js new file mode 100644 index 00000000..75e35eed --- /dev/null +++ b/test/setStats.js @@ -0,0 +1,27 @@ + window.requestAnimFrame = (function(callback){ + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function(callback){ + window.setTimeout(callback, 1000 / 30); + }; + })(); + + stats = new Stats(); + stats.setMode(0); + stats.domElement.style.position = 'fixed'; + stats.domElement.style.left = '0px'; + stats.domElement.style.top = '0px'; + document.body.appendChild(stats.domElement); + + function setStats() { + stats.begin(); + requestAnimFrame(function(){ + stats.end(); + setStats(); + }); + } + + setStats(); \ No newline at end of file diff --git a/test/unit/Node-test.js b/test/unit/Node-test.js index cbd012bb..379d9728 100644 --- a/test/unit/Node-test.js +++ b/test/unit/Node-test.js @@ -2940,19 +2940,8 @@ suite('Node', function() { assert.equal(layer.getContext().getTrace(), 'clearRect(0,0,578,200);save();transform(1,0,0,1,70,70);beginPath();arc(0,0,70,0,6.283,false);closePath();fillStyle=green;fill();lineWidth=4;strokeStyle=black;stroke();restore();clearRect(0,0,578,200);save();transform(1,0,0,1,-4,-4);drawImage([object HTMLCanvasElement],0,0);restore();'); - // setTimeout(function() { - // console.log('draw') - // layer.draw(); - // }, 1000) + //console.log(circle._cache.canvas.scene.getContext().getTrace()); - // setTimeout(function() { - // console.log('draw') - // layer.draw(); - // }, 2000) - - // setTimeout(function() { - // console.log('draw') - // layer.draw(); - // }, 3000) + assert.equal(circle._cache.canvas.scene.getContext().getTrace(), 'save();translate(74,74);beginPath();arc(0,0,70,0,6.283,false);closePath();fillStyle=green;fill();lineWidth=4;strokeStyle=black;stroke();restore();'); }); }); \ No newline at end of file