shift + sampler

Flow Fields

A grid of / - | \ characters. One sampler picks the direction per cell. Not unlike noise() and noiseSeed(), but with unexpected wave shifts every few seconds.

Core snippet
// ASCII flow field - sampler with shift
const DIRS = ['-', '/', '|', '\\'];
let sampler = createWaveSampler({
  shift: true,
  shiftInterval: 4,
  shiftDuration: 2,
  frequency: 2
});

// In draw():
for (let row = 0; row < ROWS; row++) {
  for (let col = 0; col < COLS; col++) {
    let val = sampler.sample(col * 0.5, t + row * 0.4);
    let idx = constrain(floor(map(val, -1, 1.001, 0, 4)), 0, 3);
    text(DIRS[idx], col * sz + sz / 2, row * sz + sz / 2);
  }
}