added perf tests for new FastLayer

This commit is contained in:
Eric Rowell
2014-03-09 13:15:01 -07:00
parent a9ecfd74a2
commit 852ef7056d
6 changed files with 28 additions and 76 deletions

View File

@@ -5,7 +5,7 @@
var width = 500;
var height = 300;
var VERSION = Kinetic.version === '4.7.4' || Kinetic.version === 'dev' ? 'new' : 'old';
var VERSION = Kinetic.version === 'dev' ? 'new' : 'old';
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
@@ -66,12 +66,9 @@
for (var i = 0; i < circles.length; i++) {
var x = Math.round(Math.random() * width);
var y = Math.round(Math.random() * height);
if (VERSION === 'new') {
circles[i].setPosition({x: x, y: y});
}
else {
circles[i].setPosition(x, y);
}
circles[i].setPosition({x: x, y: y});
}
lastTime = time;
@@ -83,56 +80,26 @@
}
function make_shape(color) {
if (VERSION === 'new') {
return new Kinetic.Rect({
fill: color,
width: 10,
height: 10,
transformsEnabled: "position",
listening : false
});
// return new Kinetic.Shape({
// drawFunc: function(context) {
// var _context = context._context;
// _context.beginPath();
// _context.rect(0, 0, 10, 10);
// _context.closePath();
// _context.fillStyle = color;
// _context.fill();
// }
// });
} else {
return new Kinetic.Shape(function(){
var context = this.getContext();
context.beginPath();
context.rect(0, 0, 10, 10);
context.fillStyle = color;
context.fill();
context.closePath();
});
}
return new Kinetic.Rect({
fill: color,
width: 10,
height: 10
});
}
function make_stage() {
stage = new Kinetic.Stage({
container: "container",
width: width,
height: height
});
if (VERSION === 'new') {
stage = new Kinetic.Stage({
container: "container",
width: width,
height: height,
nestedTransformsEnabled: false
});
circlesLayer = new Kinetic.Layer({
hitGraphEnabled: false
});
} else {
stage = new Kinetic.Stage("container", width, height);
console.log('create fast layer')
circlesLayer = new Kinetic.FastLayer();
}
else {
console.log('create normal layer')
circlesLayer = new Kinetic.Layer();
}
}