xxxxxxxxxx
var counter = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
performanceSetup();
stroke(0);
textSize(30);
frameRate(1);
}
function draw() {
counter ++;
background(255);
text(counter,windowWidth/2,windowHeight/2);
}
function performanceSetup(){
var onBlur = function() {
stroke(255,0,0);
noLoop();
};
var onFocus = function(){
loop();
};
if (/*@cc_on!@*/false) { // check for Internet Explorer
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
}