p5(sketch => {
let y_off = 0;
let x_off = 0;
let yoff = 0.01;
let xoff = 0.01;
sketch.setup = function() {
sketch.createCanvas(width / 2, height);
};
sketch.draw = function() {
y_off = y_off >= resolution + sketch.height * 2 ? 0 : y_off + 1;
x_off = x_off >= resolution + sketch.width * 2 ? 0 : x_off + 1;
const ypulse = pulse_shift(y_off, sketch.height * 2);
const xpulse = pulse_shift(x_off, sketch.width * 2);
sketch.loadPixels();
var buf = new ArrayBuffer(sketch.pixels.length);
var buf8 = new Uint8ClampedArray(buf);
var data = new Uint32Array(buf);
for (let y = 0; y < sketch.height * 2; y++, yoff += 0.01) {
for (let x = 0; x < sketch.width * 2; x++, xoff += 0.01) {
const index = (x + y * sketch.width * 2) * 4;
const grey = (ypulse[y] + xpulse[x]) * 255;
data[y * sketch.width * 2 + x] =
(255 << 24) |
(grey << 16) |
(grey << 8) |
grey;
}
}
sketch.pixels.set(buf8);
sketch.updatePixels();
};
})