p5.js-web-editor/static/intercept-p5.js

52 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-08-15 18:12:25 +02:00
var textOutputElement;
2016-08-12 06:11:31 +02:00
var canvasLocation ='';
funcNames = refData["classitems"].map(function(x){
return {
name: x["name"],
params: x["params"],
class: x["class"],
module: x["module"],
submodule: x["submodule"]
};
});
funcNames = funcNames.filter(function(x) {
2016-08-12 20:19:23 +02:00
var className = x["class"];
2016-08-12 06:11:31 +02:00
return (x["name"] && x["params"] && (className==='p5'));
})
funcNames.forEach(function(x){
2016-08-15 18:12:25 +02:00
let document = parent.document;
2016-08-12 06:11:31 +02:00
var originalFunc = p5.prototype[x.name];
p5.prototype[x.name] = function(){
orgArg = arguments;
2016-08-15 18:12:25 +02:00
2016-08-12 06:11:31 +02:00
if(frameCount == 0) { //for setup
2016-08-15 18:12:25 +02:00
Interceptor.setupObject = Interceptor.populateObject(x,arguments, Interceptor.setupObject, document.getElementById('textOutput-content-details'),false);
Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'));
var table = document.getElementById('textOutput-content-details');
2016-08-12 06:11:31 +02:00
table.innerHTML = '';
Interceptor.populateTable(table,Interceptor.setupObject);
}
else if(frameCount%100 == 0 ) {
2016-08-15 18:12:25 +02:00
Interceptor.drawObject = Interceptor.populateObject(x,arguments, Interceptor.drawObject, document.getElementById('textOutput-content-details'),true);
Interceptor.getSummary(Interceptor.setupObject,Interceptor.drawObject,document.getElementById('textOutput-content-summary'));
2016-08-12 06:11:31 +02:00
Interceptor.isCleared = false;
}
//reset some of the variables
else if(frameCount%100 == 1 ) {
if(!Interceptor.isCleared){
2016-08-15 18:12:25 +02:00
var table = document.getElementById('textOutput-content-details');
2016-08-12 06:11:31 +02:00
table.innerHTML = '';
Interceptor.populateTable(table,Interceptor.setupObject);
Interceptor.populateTable(table,Interceptor.drawObject);
}
Interceptor.drawObject = Interceptor.clearVariables(Interceptor.drawObject);
}
return originalFunc.apply(this,arguments);
}
});