{
const { canvas, ctx, imageData, tStep } = canvasStuff,
{ width, height } = canvas,
{ data } = imageData;
function drawPlasma() {
const { t } = canvasStuff;
var x, y;
for (let i = 0; i < width; i++) {
for (let j = 0; j < height; j++) {
x = (i / width) * 10;
y = (j / height) * 10;
const r = getPixel(x, y, t) * 0.5 + 0.5;
const g = getPixel(x + 0.2, y, t) * 0.5 + 0.5;
data[(i + j * width) * 4 + 0] = r * 200;
data[(i + j * width) * 4 + 1] = g * 200;
data[(i + j * width) * 4 + 2] = 0;
data[(i + j * width) * 4 + 3] = 255;
}
}
canvasStuff.t += tStep;
ctx.putImageData(imageData, 0, 0);
statsMonitor.update();
}
while (toggle) {
drawPlasma();
yield performance.now();
}
}