This browser has no WebGPU, so the sketch cannot run here. The program is below, and it runs in a current Chrome, Edge or Safari.
Oscilloscope
Use sine and cosine to trace a 2D oscillating point
///////////////////////////////////////////////////////////////
// Oscilloscope
// Sweep a signal from left to right across the display.
///////////////////////////////////////////////////////////////
&time = mlt(step, 0.01);
// horizontal sweep
&phase = frc(mlt(&time, 0.08));
&x = sub(mlt(&phase, 1.8), 0.9);
// signal
&signal =
mlt(
sin(mlt(&phase, 10)),
0.9
);
&pos = (&x, &signal);
// draw the moving beam
&trace = sml(dst(C, &pos), 0.025);
#A {
dim = (256, 256);
run = mlt(add(#, &trace), 0.99);
}
~A {
col = (0.1, #A, 0.1);
scl = (2);
}