Code-Driven Visuals: How AI Reshapes the Technical Boundaries of Presentations
This article examines how a large language model can turn a natural language prompt into an interactive presentation with camera movement and original music by writing code, rather than by generating visual assets. It abstracts a general engineering framework from this public case, covering a five-layer architecture, code-built cinematic techniques, transition design, code-synthesized audio and synchronization, interaction, performance and accessibility, the generation workflow and prompt constraints, evaluation criteria and common pitfalls, and a general cloud deployment approach. The goal is to show how code-driven presentations can evolve from static slide collections into programmable real-time scenes.
When a natural language prompt turns into an interactive piece with camera movement and original music in about forty minutes, the point worth attention is not how flashy the output looks, but the technical path it validates: visual expressiveness can be built by a large language model writing code, without relying on visual asset generation models. This article uses that public case as a starting point to abstract a general engineering framework for moving code-driven presentations from a collection of static pages to programmable real-time scenes.
The Technical Problem Behind the Result
Traditional presentation tools assume that one slide maps to one static layout, with fixed element positions and transitions driven by preset animations. The case described here works differently: a page can be a camera shot, a 3D space, or even a state machine that keeps evolving. What supports this form is not a new asset generation capability, but the combination of three general capabilities:
- Code generation: the model translates narrative intent into a runnable structured program.
- Real-time rendering: a graphics pipeline in the browser or a container draws frame by frame.
- State and interaction: scrolling, clicks, and keyboard events drive the scene forward.
In other words, the presentation is redefined as a front-end application. This also explains why the demands on the model center on long-context consistency, stable structured output, and self-correction during debugging, rather than pixel-level image synthesis.
Overall Architecture: Five Decoupled Layers
To engineer this kind of work, decouple it into five layers instead of piling all logic into a single file.
- Narrative layer: defines chapters, arguments, and the emotional curve, and outputs a render-agnostic structural description.
- Scene layer: maps narrative nodes to a scene graph containing cameras, lights, geometry, and materials.
- Rendering layer: handles per-frame drawing, post-processing, and resolution adaptation.
- Interaction layer: manages progress, events, accessibility, and state rollback.
- Resource layer: covers audio synthesis, fonts, caching, and fallback assets.
The core data structure of the narrative layer can be abstracted as:
{"chapters": [{"id": "c1","beat": "Problem statement","duration": 12,"camera": { "from": [0, 2, 8], "to": [0, 1.2, 5], "easing": "inOutCubic" },"entities": ["grid", "text:Title", "chart:growth"],"transition": { "type": "dolly", "overlap": 0.6 }}]}
The benefit of this data-driven narrative is that the model only needs to produce stable, verifiable JSON, while rendering and interaction are handled by deterministic code. This significantly reduces the chance of runtime errors.
Visuals: Building Cinematic Language With Code
A cinematic feel comes from three things: continuous camera movement, layered depth of field and lighting, and controllable editing rhythm.
Camera and easing: avoid linear interpolation. Use cubic easing or spring damping so movement has a sense of weight at the start and stop.
function easeInOutCubic(t) {return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;}function updateCamera(chapter, t) {const k = easeInOutCubic(Math.min(Math.max(t / chapter.duration, 0), 1));camera.position.lerpVectors(chapter.camera.from, chapter.camera.to, k);camera.lookAt(target);}
Materials and lighting: build on physically based lighting, control the contrast between roughness and metalness, use a few strong light sources to shape silhouettes, and fill shadows with ambient light. Volumetric fog and light post-processing (tone mapping, slight chromatic aberration, grain) can noticeably improve the finished look, but they must be counted against the performance budget.
Geometry and particles: prefer parametric geometry and instanced rendering. Generate large shape variations from a small number of parameter changes instead of loading external model files.
Transition Design: Making the “Slide Feel” a Narrative Thread
The most interesting design in the case keeps office-software visual symbols such as selection boxes, thumbnails, and cursors, and brings them back repeatedly as the selected object expands from text to charts, planets, and eventually the whole screen. This is a form of meta-narrative: the audience is always aware that they are watching a presentation, while the presentation rewrites itself.
In engineering terms, transitions can be abstracted into three types:
- Spatial: camera fly-throughs, push and pull, and orbits, suited to macro switches between chapters.
- Morphological: geometry merging, splitting, and particle reassembly, suited to concept evolution.
- Interface: expanding selection boxes, enlarging thumbnails, and advancing scrollbars, suited to emphasizing document properties.
All three types share the same timeline and easing functions and are dispatched through transition.type, which keeps the rhythm consistent.
Audio and Synchronization: Synthesis Instead of Asset Collage
Music can also be generated in code: stack harmonics with oscillators to build timbre, use envelopes to control attack and decay, use noise and filters to create atmosphere layers, and align transition timestamps to a beat grid. The key is to make the audio clock the master clock and sample rendering frames by audio time to avoid audio-visual drift.
const ctx = new AudioContext();function playPad(freq, start, dur) {const osc = ctx.createOscillator();const gain = ctx.createGain();osc.type = 'sawtooth';osc.frequency.value = freq;gain.gain.setValueAtTime(0, start);gain.gain.linearRampToValueAtTime(0.12, start + 0.4);gain.gain.exponentialRampToValueAtTime(0.001, start + dur);osc.connect(gain).connect(ctx.destination);osc.start(start); osc.stop(start + dur);}
Interaction, Performance, and Accessibility
Interactivity means handling state: progress index, scene caching, event interruption, and rollback. Set a budget per chapter (draw calls, triangle count, texture memory) and provide three degradation levels: full effects, simplified post-processing, and a static text-and-image fallback.
const budget = { drawCalls: 220, triangles: 8e5, textureMB: 180 };function degrade(level) {if (level >= 1) postProcessing.enabled = false;if (level >= 2) particles.count = Math.floor(particles.count * 0.3);if (level >= 3) showStaticFallback();}
Accessibility cannot be ignored either: provide a “reduce motion” toggle for animations, ensure keyboard operability, and give key text readable contrast and alternative text.
Generation Workflow and Prompt Engineering
Stable output depends on process, not inspiration. A four-step approach is recommended: first have the model output the narrative JSON and a scene list; then generate the rendering skeleton and placeholder geometry; then fill in materials, transitions, and audio chapter by chapter; finally enter a self-testing loop in which the model reads console errors and frame rate data and corrects them itself. Prompts should state explicit constraints: code only, no external assets, a fixed technology stack and performance limits, and modular, rollback-capable structure.
Evaluation Criteria and Common Pitfalls
Evaluation should go beyond how impressive the result looks. Suggested dimensions include narrative clarity, transition consistency, first-screen load time, frame rate on mid- and low-end devices, interaction rollback, and code maintainability. Common pitfalls include a single-file monolith that is hard to debug, excessive post-processing that causes heat and dropped frames, separate audio and rendering clocks that cause drift, and ignoring the reduce-motion preference.
A General Approach to Running It in the Cloud
To turn this kind of work into a deliverable product capability, combine general cloud categories: object storage for build artifacts and static fallback assets, a content delivery network to reduce first-screen latency, a container platform to run build and batch rendering jobs, a message queue to decouple long-running tasks, and logging and monitoring with alerts to track error rates and frame rate metrics. Baidu AI Cloud can provide corresponding infrastructure across these general categories, helping teams deliver creative coding as a stable engineering output.
Conclusion
The real lesson from this widely shared piece is that it redefines the presentation from a layout problem into a real-time graphics and narrative orchestration problem. When a model has sufficient structured output and self-correction ability, code becomes the most general visual language: it does not depend on an asset library, and it can be versioned, tested, and degraded. For developers, the worthwhile investment is not chasing a single show of skill, but building data-driven narrative structures, a reusable transition library, and strict performance budgets. That is what turns occasional spectacle into stable output capacity.
