Added timer/statistics for rendering

This commit is contained in:
Niklas von Hertzen
2011-07-17 02:42:45 +03:00
parent 3193e1a20b
commit 45381454b4
7 changed files with 61 additions and 21 deletions

View File

@@ -13,18 +13,28 @@
new html2canvas(this.get(0), {
logging: true,
ready: function(canvas) {
ready: function(renderer) {
var finishTime = new Date();
// console.log((finishTime.getTime()-timer)/1000);
document.body.appendChild(renderer.canvas);
document.body.appendChild(canvas);
var canvas = $(canvas);
var canvas = $(renderer.canvas);
canvas.css('position','absolute')
.css('left',0).css('top',0);
// $('body').append(canvas);
$(canvas).siblings().toggle();
throwMessage('Screenshot created in '+ ((finishTime.getTime()-timer)/1000) + " seconds<br />Total of "+renderer.numDraws+" draws performed",4000);
$(window).click(function(){
if (!canvas.is(':visible')){
$(canvas).toggle().siblings().toggle();
@@ -42,15 +52,16 @@
});
function throwMessage(msg){
function throwMessage(msg,duration){
window.clearTimeout(timeoutTimer);
timeoutTimer = window.setTimeout(function(){
message.fadeOut(function(){
message.remove();
});
},2000);
},duration || 2000);
$(message).remove();
message = $('<div />').text(msg).css({
message = $('<div />').html(msg).css({
margin:0,
padding:10,
background: "#000",
@@ -64,6 +75,7 @@
borderRadius:12,
width:'auto',
height:'auto',
textAlign:'center',
textDecoration:'none'
}).hide().fadeIn().appendTo('body');
}