Building Interactive Demos Entirely in Code
Traditional slide decks slice a story into static canvases. This article explains why code-driven scenes—cameras, objects, timelines, and interaction state—fit complex, replayable technical demos better than pixel generation, and how to turn prompts into executable specs, a scene model, motion tokens, accessibility, and a staged generation workflow.
Traditional presentations cut information into static canvases: titles, bullets, and charts appear in sequence, with fades as the usual transition. The audience has to assemble the fragments into a story. Treat each “page” as a computable scene—camera, objects, timeline, and interaction state driven by a program—and the talk stops being page-flipping and becomes progress through a single narrative space.
Large language models do not have to generate pixel images and paste them into slides. They are stronger at writing runnable graphics code that a browser or runtime draws live. Rhythm, particles, orbits, and infographics can come from the same program rather than an external asset library.
Why a code path fits complex demos
Pixel generators excel at a single frame’s look, but they struggle with object consistency across shots, clickable regions, and repeatable playback. On a code path, geometry, color, easing, and events are explicit data: change a parameter and the same shot replays; zoom, pause, and jump do not break composition. Without external images, style still unifies through palette, lighting, and motion language.
The cost is harder engineering constraints. Frame budget, text readability, fallbacks, and a state machine must be designed up front, or “cinematic” motion becomes stutter on low-end devices.
Effects that fit code include procedural charts and data mapping, time-based camera moves, simple 3D volumes and particles, SVG path morphs, full-screen transition masks, and promoting a selected object from “a point on a chart” to “the subject of the scene.” Effects that are a poor fit include photoreal close-ups of people, brand films that require copyrighted assets, and huge scenes that cannot hold frame rate in the target runtime.
Converge the prompt into an executable spec
Open-ended prompts can spark layout and pacing, but delivery cannot stop at “make it stunning.” Rewrite intent as a spec before you ship, including at least:
- Narrative goal: one judgment the audience should remember, not a list of assets.
- Scene sequence: spatial metaphor, objects that enter, dwell time, and how they leave.
- Interaction contract: what can be clicked, dragged, or jumped, and feedback for invalid actions.
- Constraints: code-only, no external binary assets, target resolution, minimum frame rate, keyboard access if required.
- Style anchors: even without a named art movement, agree contrast, minimum type size, and a cap on motion duration so effects do not swallow readability.
Once the spec is structured, the model fills in implementation; people check that it still serves the story. Open creative instructions do not cancel acceptance criteria—they need a clearer definition of done.
A scene model, not a page model
Describe the whole talk in one data structure instead of scattered page scripts. Conceptually each scene has an id, duration, camera or viewport, a list of layers, enter/exit animation, and optional interaction hooks. The player does three things: switch scenes on time or user input, map progress to layer interpolation, and send hit tests to the current interactive objects.
Illustrative structure (layering only, not a platform API):
Presentationscenes[]id, duration, cameralayers[]: shape | text | chart | mesh | particletransitionIn / transitionOutbindings: event -> state changetimeline: sequence or graph of scene idstheme: palette, type scale, motion tokens
The sense that “the slide is rewriting itself” comes from reusing one visual grammar at different scales: selection boxes, guides, and a playhead first frame a chart, then a celestial body, then the whole frame. Do not invent a new UI per shot. Encode select, focus, and reveal as reusable motion tokens—duration, easing, stroke weight in one place—while scenes only declare which token they use.
Graphics and motion
Prefer vectors for 2D information: paths, type, and simple charts stay sharp when scaled and morph well in transitions. Use 3D for spatial relationships, not to put every label in perspective; key conclusions should sit on a plane facing the audience. Particles, noise, and procedural textures fill atmosphere, with count caps and quality switches by distance or device.
Split two clocks: a presentation clock (pausable, scrubbable) and wall-clock time (ambient micro-motion only). Entrance animation should subscribe to the presentation clock so a jump to a chapter can recompute state instead of relying on leftover side effects. Prefer reversible interpolation: shared elements moving from the previous bounding box to the next feel more continuous than a hard cut to black and make “go back a shot” easier.
Color and type must meet contrast and line length first, then style. If a moving background hurts text contrast, put a stable mask under the copy rather than hoping the audience adapts to flicker. Motion should finish shorter than the narrative pause so the camera does not leave before the text is read.
Interaction, state, and accessibility
Interactive does not mean everything is clickable. Each scene should expose only actions tied to the current claim: expand a data dimension, switch a future scenario, pause an orbit to compare positions. State should be serializable so you can share a link to a frame or reproduce it in a review. Hit targets should be larger than the visual hotspots; keyboard and focus order should cover the main path. Decorative motion should respect reduced-motion preferences with a static or simplified path.
Error handling is part of the experience: on a script failure, fall back to a plain-text outline instead of a blank screen. When assets are inlined or generated, offline playback is simpler, but watch bundle size so a single file is not too large to open.
Generate, review, iterate
With a coding assistant, use three rounds instead of generating the whole film at once. Round one: scene graph and copy, to test whether the argument holds. Round two: player skeleton plus two representative scenes—one information-dense, one spatially complex—to probe frame rate and structure. Round three: remaining shots and unified theme tokens.
A concrete review list: can the core judgment be told in three minutes; do arbitrary jumps avoid hidden state; does text overflow at the target width; does memory climb over minutes of continuous play; can a pointer-free device complete the main path. Do not substitute “it looks stunning” for these checks. If a shot only works on high-end hardware, ship a degraded scene rather than assuming every audience environment matches.
Estimate compute and time by task boundary: open visual exploration means more rework; a structured spec is cheaper. Budget spent on scene design and the state model usually beats redrawing effects. For cloud collaboration, versioned source in object storage, a build pipeline for previews, and logs/metrics on preview error rates are ordinary engineering—not tied to a particular visual model.
Limits and what to deliver
Code can produce short-film-like shots, simple 3D space, and procedural music locked to rhythm, but “everything is code” is not the same as finished production. If audio comes from oscillators or sample sequences, watch loudness, loop seams, and ducking around voiceover; without narration, key sentences must still be readable from the picture alone. Do not sell unverified capability as a stable product feature, or a one-off impressive sample as a repeatable performance promise.
Ship four artifacts: a runnable demo, the scene spec, theme and motion-token notes, and known degradation conditions. Later maintainers then change data and a few layers instead of patching an unreproducible generate. Competitiveness is not how flashy one page is, but whether story, interaction, and runtime cost all hold at once.
