ANIMATIX WALKTHROUGH · ALGORITHMIC THEATRE
Eight bars, completely out of order. An insertion sort walks each key bar left past its larger neighbours — twenty-one seconds of choreography in which every comparison lights a tick and every swap shifts physical bars. Emitted purely at compile time.
Overture sets the premise, the sort executes with live physical bar exchanges and counter ticks, and the finale confirms ascending stability and asymptotic algorithmic complexity.
Establishes the contract: beats are generated by running code, not drawn manually.
Callouts track the active key while comparison and swap tick meters increment.
The array rests in sorted order, presenting memory and comparison audit stats.
Rather than hand-drawing twenty keyframes in an animation timeline GUI, an Animatix function executes during DSL compilation, emitting keyframe beats directly from the sorting loops.
[step: 2400ms] modifier
Purity: Deterministic event trace
insertion_sort.amx)
▾
fn insertion_sort(bars, values: List<Num>, comp_ticks, swap_ticks) {
let order = {0, 1, 2, 3, 4, 5, 6, 7}
for key in {1, 2, 3, 4, 5, 6, 7} [step: 2400ms] {
key_note.target = bars.bar[order[key]] [300ms]
for j in {0, 1, 2, 3, 4, 5, 6} [step: 300ms] {
if j < key {
comp_ticks.t[ci].color = accent.info [120ms]
if values[order[key - j]] < values[order[key - j - 1]] {
swap bars.bar[order[key - j]], bars.bar[order[key - j - 1]] [260ms]
let order = list_swap(order, key - j, key - j - 1)
swap_ticks.t[si].color = accent.warning [120ms]
}
}
}
}
}
Watch the key callout target the active element. For every smaller value encountered on the left,
the swap keyword smoothly transitions both rectangles simultaneously while the swap tick lights in amber.
The array rests in guaranteed ascending order: [5, 12, 17, 31, 42, 68, 76, 93]. Because insertion sort operates in-place, the auxiliary space complexity is strictly O(1) extra memory.