Imlement Stats in the dev version of Paper.

This commit is contained in:
Jonathan Puckey 2011-05-05 20:23:22 +01:00
parent 7e24a9170f
commit 140f7dee44
2 changed files with 17 additions and 1 deletions

View file

@ -65,6 +65,18 @@ var Document = this.Document = Base.extend({
this.views = [this.activeView];
this._selectedItems = {};
this._selectedItemCount = 0;
// TODO: test this on IE:
if (this.canvas.attributes.stats) {
this.stats = new Stats();
// Align top-left to the canvas
var element = this.stats.domElement,
style = element.style,
offset = Element.getOffset(this.canvas);
style.position = 'absolute';
style.left = offset.x + 'px';
style.top = offset.y + 'px';
document.body.appendChild(element);
}
},
getSize: function() {
@ -144,6 +156,8 @@ var Document = this.Document = Base.extend({
draw: function() {
if (this.canvas) {
if (this.stats)
this.stats.update();
var ctx = this.context;
ctx.save();

View file

@ -72,7 +72,9 @@ var sources = [
'src/util/Numerical.js',
'src/util/PaperScript.js',
'src/ui/Key.js'
'src/ui/Key.js',
'lib/Stats.js'
];
// Load unit tests after library if asked to do so