Code-Generated Visuals: An Engineering Practice for Rendering Presentations with Code
This article examines how large language models can produce visual content by writing code instead of relying on image assets or pre-recorded audio. It breaks down the approach into a four-layer architecture (schema, compiler, runtime, export), defines measurable quality metrics, and outlines solutions to common engineering challenges such as performance jitter, transition continuity, audio-visual sync, accessibility, and cost control. A quality checklist and general cloud deployment pattern are also included.
1. The Technical Premise: Visual Generation Does Not Always Require Visual Generation Models
A recent code-only presentation-style demo sparked discussion: no external images, no pre-recorded audio, and every chart, text block, globe, sun, and camera move was driven entirely by code. It is worth reviewing from an engineering perspective not because of any specific tool, but because it highlights a long-underestimated capability: large language models can produce visual content by writing code.
Traditionally, building a presentation with transitions, camera language, and 3D quality requires art assets, animation software, render farms, and manual tuning. The code-only path compresses the entire pipeline into “structured description → programmatic generation → execution in a browser or renderer.” This brings three direct benefits:
- Versionable: scenes are source code, so they can go through code review, diff comparison, and rollback;
- Parameterizable: color schemes, durations, camera focal length, and particle counts are all variables, making it easy to produce multiple variants in batch;
- Automatable: generation, rendering, and publishing can be chained into a pipeline, reducing manual handoffs.
It is worth emphasizing that this capability is not a proprietary feature of any single vendor, but a general engineering method: driving real-time rendering with declarative scene descriptions, combined with a deterministic timeline, and outputting results in a standard runtime environment.
2. Breaking Down the Capability: Turning “Looks Good” into Computable Metrics
To make a model reliably produce high-quality visuals, first decompose vague aesthetic requirements into verifiable technical metrics:
- Scene graph scale: node count, hierarchy depth, material variety;
- Timeline precision: keyframe density, easing function types, total duration and frame rate;
- Rendering budget: draw calls per frame, triangle count, texture memory usage;
- Interaction consistency: whether selected, hover, and focus order states meet accessibility requirements;
- Reproducibility: whether the same input produces the same result (whether the random seed is fixed).
With these metrics, prompts and code generation have acceptance criteria rather than “looks about right.”
3. Reference Architecture: Four Layers Supporting Code-Only Visuals
1. Description Layer (Schema)
Use structured data to describe “what objects exist, what relationships they have, and how they change over time.” Example:
{"scene": "solar","duration": 42,"fps": 60,"objects": [{"id": "sun", "type": "sphere", "r": 3.0, "emissive": "#ffb347"},{"id": "earth", "type": "sphere", "r": 0.4, "orbit": {"center": "sun", "radius": 8, "period": 12}}],"camera": {"fov": 45, "path": "dolly_in", "from": [0, 4, 20], "to": [0, 2, 10]}}
2. Compiler Layer
Compile the description into an intermediate representation that the renderer can consume: object pools, material caches, animation tracks. This layer handles validation (for example, orbit periods must divide the total duration evenly to avoid loop seams).
3. Runtime Layer
Evaluate frame by frame in a standard runtime environment. The core is a deterministic timeline: drive by frame number rather than wall-clock time to ensure recording and real-time preview stay consistent.
function sample(track, frame, fps) {const t = frame / fps;const k = track.keys;// Find the interval and apply easing interpolation (linear here; replaceable with cubic easing)for (let i = 0; i < k.length - 1; i++) {if (t >= k[i].t && t <= k[i + 1].t) {const u = (t - k[i].t) / (k[i + 1].t - k[i].t);return k[i].v + (k[i + 1].v - k[i].v) * u;}}return k[k.length - 1].v;}
4. Export Layer
Real-time preview is for creation; offline frame-by-frame rendering is for delivery. Offline rendering can stage frame sequences in object storage, then encode them in parallel via containerized tasks, and finally distribute through a content delivery network. The whole process is tracked with logging and monitoring/alerting for failure rates and elapsed time.
4. Key Engineering Challenges and Countermeasures
- Performance jitter: heavy alpha blending and particles can slow down frame rate. Countermeasures: instanced drawing, on-demand downsampling, and baking static parts into textures.
- Transition continuity: office-software-style “selection box” markers work because they provide a visual anchor across scenes. In engineering terms, this can be abstracted as a “global pointer object” that keeps its identity across scene switches and only changes its target.
- Audio-visual sync: procedural audio also schedules note triggers by frame number to avoid audio-video drift.
- Accessibility: provide pause, reduced-motion, and text alternatives for animations to avoid dizziness and information asymmetry.
- Cost control: use the “high-reasoning tier + long context” for one-time blueprint generation, and put repeated rendering on cheaper compute; set budget thresholds and alerts for quota consumption.
5. Quality Acceptance Checklist
- Two generations with the same seed produce identical keyframe values;
- Time to interactive on the first frame is below the set threshold, and long tasks provide progress feedback;
- On low-end devices with “reduced motion” enabled, the narrative is still complete;
- All asset sources are traceable, confirming no external copyright dependencies;
- Render failures are retryable and idempotent, and artifacts carry checksums.
6. General Cloud Deployment Practices
To productize the creation workflow, a combination of general cloud capabilities can be used: object storage for description files and frame artifacts, a container platform for stateless rendering tasks with queue-based scaling, a message queue to decouple “generation—rendering—encoding,” and a logging and monitoring system to observe end-to-end latency. The general cloud product categories offered by Baidu AI Cloud can serve as the underlying platform for such an architecture; specific selections should be based on load-test data.
7. Conclusion
“The greatest ever” is an emotional expression; what is truly replicable is the methodology: compile visual creativity into deterministic programs. When scenes, cameras, and sound can all be described, evaluated, and replayed, creative production shifts from craftsmanship to a measurable, collaborative, and scalable engineering process. The model plays the role of “compiler author,” while engineering discipline determines whether the work can be delivered reliably.
