ANIMATIX WALKTHROUGH · ALGORITHMIC THEATRE

Sorting, Staged

  • 4 interactive stages
  • WebGPU 60 FPS vector canvas
  • 1 build-time timeline fn
  • 0 hand-written swaps

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.

Fig 00 // Complete Sorting Theatre (3 Scenes)
pkg-slim · 1.6MB 60 FPS WEBGPU
Complete Suite · Algorithmic Choreography

Three Acts of Insertion Sort

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.

scene.amx ↗
Input Array: [42, 17, 93, 5, 68, 31, 76, 12] Algorithm: In-place Insertion Sort Complexity: O(N²) worst-case, O(1) space
01
The Overture

Establishes the contract: beats are generated by running code, not drawn manually.

02
Active Sort

Callouts track the active key while comparison and swap tick meters increment.

03
The Finale

The array rests in sorted order, presenting memory and comparison audit stats.

Fig 01 // Build-Time Timeline Function Contract
pkg-slim · 1.6MB 60 FPS WEBGPU
Act 01 · Code as Director

The Overture: Code Emits the Play

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.

overture.amx ↗
Mechanism: Build-time AST Evaluation Pacing: [step: 2400ms] modifier Purity: Deterministic event trace
View Timeline Generator Function (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]
        }
      }
    }
  }
}
Fig 02 // Live Bar Swaps & Algorithmic Counters
pkg-slim · 1.6MB 60 FPS WEBGPU
Act 02 · Algorithmic Mechanics

Insertion Sort in Motion

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.

sort.amx ↗
Comparisons: 28 tick indicators Swaps: 15 exchange transitions Callout: Adaptive target tracking
Fig 03 // Ascending Order Rest & Memory Audit
pkg-slim · 1.6MB 60 FPS WEBGPU
Act 03 · Post-Condition Verification

Sorted Stability & Memory Footprint

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.

finale.amx ↗
Final Array: 8 sorted heights Space Complexity: O(1) aux memory Stability: Preserves equal keys