in toolkit/jb/svg.js [574:614]
function createP5ToDisplayPixels(node, trgWidth, trgHeight, getPixels) {
var srcWidth = window.innerWidth;
var srcHeight = window.innerHeight;
return function(p) {
var setupCalled = false;
p.preload = function() {};
p.setup = function() { var c = p.createCanvas(srcWidth, srcHeight);
c.addClass('p5-inner-canvas');
c.canvas.style.transform = 'scale(' + (trgWidth / srcWidth) + ',' +
(trgHeight / srcHeight) + ')';
p.noLoop();
setupCalled = true; }
p.draw = function() {
var pixels = getPixels();
if (!pixels) return;
p.loadPixels();
var source = pixels;
var target = p.pixels;
var d = p.pixelDensity();
for (var x = 0; x < srcWidth; x++) {
for (var y = 0; y < srcHeight; y++) {
for (var i = 0; i < d; i++) {
for (var j = 0; j < d; j++) {
pixelIdx = 4 * ((y * d + j) * srcWidth * d + (x * d + i));
target[pixelIdx] = source[pixelIdx];
target[pixelIdx+1] = source[pixelIdx+1];
target[pixelIdx+2] = source[pixelIdx+2];
target[pixelIdx+3] = source[pixelIdx+3];
}
}
}
}
p.updatePixels();
};
var prevRedraw = p.redraw;
p.redraw = function() {
if (!setupCalled) return;
prevRedraw.call(this);
};
}
}