MCPcopy Create free account
hub / github.com/corbanbrook/dsp.js / init

Function init

examples/js/processing.js:12240–12273  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12238
12239 // Automatic Initialization Method
12240 var init = function() {
12241 var canvas = document.getElementsByTagName('canvas');
12242
12243 for (var i = 0, l = canvas.length; i < l; i++) {
12244 // datasrc and data-src are deprecated.
12245 var processingSources = canvas[i].getAttribute('data-processing-sources');
12246 if (processingSources === null) {
12247 // Temporary fallback for datasrc and data-src
12248 processingSources = canvas[i].getAttribute('data-src');
12249 if (processingSources === null) {
12250 processingSources = canvas[i].getAttribute('datasrc');
12251 }
12252 }
12253 if (processingSources) {
12254 // The problem: if the HTML canvas dimensions differ from the
12255 // dimensions specified in the size() call in the sketch, for
12256 // 3D sketches, browsers will either not render or render the
12257 // scene incorrectly. To fix this, we need to adjust the attributes
12258 // of the canvas width and height.
12259 // Get the source, we'll need to find what the user has used in size()
12260 var filenames = processingSources.split(' ');
12261 var code = "";
12262 for (var j = 0, fl = filenames.length; j < fl; j++) {
12263 if (filenames[j]) {
12264 var block = ajax(filenames[j]);
12265 if (block !== false) {
12266 code += ";\n" + block;
12267 }
12268 }
12269 }
12270 Processing.addInstance(new Processing(canvas[i], code));
12271 }
12272 }
12273 };
12274
12275 document.addEventListener('DOMContentLoaded', function() {
12276 init();

Callers 1

processing.jsFile · 0.85

Calls 1

ajaxFunction · 0.85

Tested by

no test coverage detected