Animation: Sequencing and Control Flow

Oscillators make things move. Smoothing makes things flow. Timing decides when. But you also need logic. Which thing moves? What comes next? How do you step through states?

That’s what sequencing nodes are for.

Counter

Counts up, down, or both. Each trigger increments (or decrements) by a configurable step. At the limits you can wrap (loop back to the start), clamp (stay at the limit), or ping-pong (reverse direction).

Connect a metro to a counter and you’ve got a stepping index. Feed that index into a select node and you’re cycling through options. Feed it into a spread index and you’re scanning through data.

I added overflow protection here. If you set a range where max is less than or equal to min, the counter clamps instead of overflowing. The kind of bug that only shows up at 2am during an installation when someone accidentally inverts the range.

Select

Picks one of N inputs based on an index. The switch statement of node graphs. Wire up five different values, feed an index, get the selected one out.

The index wraps, so a counter going 0, 1, 2, 3, 0, 1, 2, 3 cycles through four inputs endlessly. Combined with a spread, you can select from hundreds of options.

Switch

The binary version of Select. Two inputs, one boolean, one output. True picks A, false picks B.

Dead simple. Used everywhere. “If this condition, use this value, otherwise use that one.”

Toggle

Each bang flips the state. First bang turns it on, second bang turns it off, third bang turns it on again. Like a light switch.

Connect a pulse or a button press to a toggle and you’ve got persistent on/off state from momentary triggers.

FlipFlop

Set/reset flip-flop. Two trigger inputs: set (goes to true) and reset (goes to false). Unlike toggle, each input has a deterministic result. Set always turns on. Reset always turns off.

Useful when you have separate “start” and “stop” events rather than a single “toggle” event.

Sequencer

Steps through a spread of values on each trigger. Feed it a spread of [red, green, blue, yellow] and a metro, and it outputs red, then green, then blue, then yellow, then back to red.

This is the step sequencer from music production, but for any data type. Step through colors, positions, scales, opacities, whatever you want. The spread defines the sequence, the trigger advances it.

SampleAndHold

Grabs the current input value when triggered and holds it until the next trigger. Between triggers, the output is frozen.

Classic synthesizer concept. A noise signal through a sample-and-hold becomes a series of random steps, changing only on each trigger. A smooth signal through a sample-and-hold becomes a staircase. Any continuous signal becomes discrete events.

Combined with a metro, you get regular snapshots of a changing value. Combined with an OnChange, you capture the value at the moment something happens.

All stateful, all undoable

Every one of these nodes maintains state across frames. The counter remembers its count. The toggle remembers if it’s on or off. The sequencer remembers which step it’s on.

And every one of them implements save_state and restore_state, so Ctrl+Z puts the state back where it was. Undo a bang that advanced a sequencer? The sequencer steps back. Undo a toggle? It flips back.

This was not trivial to implement, but it was non-negotiable. Undo has to work on everything or it works on nothing.

← Back to blog