Example 11 — Time Control
Time Strata
Time is a plain number — no auto-advance. Move the mouse to scrub a time window; 16 coloured layers each freeze the wave at a different t value, creating geological strata that shift as you move.
Core snippet
// Time is just a number — no automatic advancement.
// Mouse X scrubs the time window; each layer freezes at its own t.
const timeBase = map(mouseX, 0, width, 0, 8);
for (let i = 0; i < LAYERS; i++) {
const t = timeBase + (i / LAYERS) * WAVE_WINDOW;
const y0 = map(i, 0, LAYERS-1, 40, height-40);
beginShape();
for (let x = 0; x <= width; x += 3) {
const dy = Waves.wave(x * 0.015, {
wave: 'classic sine', t,
amplitude: 30
});
vertex(x, y0 + dy);
}
endShape();
}