Animated SVG and Code-Based Rendering: Testing LLM Visual Coding Capabilities
Two practical tasks—an animated SVG and a code-rendered afternoon interior—show where large language models succeed in visual code generation and where they still struggle. This article examines code structure, interaction, lighting, materials, and maintainability, then outlines an evaluation approach that combines automated checks with human visual review.
Animated SVG and Code-Based Rendering: Testing LLM Visual Coding Capabilities
As flagship models evolve, code generation, frontend interaction, and multimodal understanding are increasingly evaluated together. For developers, the important question is no longer simply whether a model can write code. It is whether that code runs reliably, remains maintainable, and produces visually coherent results under defined constraints.
This article examines two tasks: animated SVG generation and code-based lighting and rendering. Together, they illustrate the capabilities and limitations of LLM-generated visual code, along with practical approaches to evaluation and production use.
1. Beyond “It Runs”: Visual Quality and Maintainability
Early code-generation benchmarks often focused on whether output compiled or executed. As AI coding tools enter production workflows, evaluation needs to cover at least five dimensions:
- Executability: Can the code run independently, without uncontrolled external dependencies?
- Visual coherence: Do composition, proportions, occlusion, materials, and lighting make sense?
- Interaction completeness: Do animation, pause controls, speed adjustments, and theme switching work together consistently?
- Maintainability: Is the structure clear? Are state and rendering logic separated? Can developers modify the result easily?
- Performance budget: Are initial payload size, frame rate, and rendering costs acceptable?
A single demo cannot establish a model’s overall capabilities, but it can reveal recurring weaknesses. The two tasks below cover structured animation generation and offline or real-time rendering code. The first emphasizes engineering organization; the second places greater demands on visual judgment and graphics knowledge.
2. Task One: Animated SVG, from Execution to Interaction
A neutral, reproducible prompt is:
Generate an animated SVG of a pelican riding a bicycle.
This familiar test requires a model to coordinate a character, a vehicle, their movement, and the surrounding scene. A more complete implementation may also include controls within the SVG.
In the reported test, a preview version of a code-generation model, using a high-reasoning setting, produced a relatively complete scene: a hat-wearing pelican cycling beside the sea, rotating wheels, a trailing scarf, and controls for pausing, adjusting pedaling speed, and switching between day and night. After the speed was increased and the result exported as a standalone SVG, the animation continued to work when opened offline.
From an engineering perspective, the value is not just the drawing’s resemblance to the subject. It is also whether the implementation can be broken into understandable components. A well-organized SVG animation should have a structure along these lines:
<svg viewBox="0 0 800 450" xmlns="http://www.w3.org/2000/svg"><g id="scene"><g id="background"><!-- Sea, sky, and road --></g><g id="bike"><g id="wheel-front"><!-- Spokes and rim --></g><g id="wheel-back"></g><g id="frame"></g></g><g id="pelican"><g id="body"></g><g id="scarf"></g><g id="head"></g></g></g><script><![CDATA[let speed = 1;let paused = false;function tick(dt) {if (paused) return;// Rotate wheels, sway the scarf, and move the background.// Separate state from drawing to simplify pausing and speed changes.}]]></script></svg>
This task suggests that models can handle layering, grouping, state controls, and basic easing reasonably well. However, acceptance testing still needs to check several details:
- Does the motion follow physical intuition?
- Does the scarf’s movement respond to speed?
- Does day/night switching preserve contrast rather than merely changing colors?
- Does the exported file depend on external scripts or network-loaded fonts?
For developers, the production value of animated SVG lies in being embeddable, usable offline, and editable—not merely in producing an attractive screenshot.
3. Task Two: Code-Based Rendering Shows Promise in Lighting but Weaker Visual Judgment
The second task asks the model to create the atmosphere of a quiet afternoon through light and shadow. The original prompt can be rendered in English as:
Use any coding technique you know to create an image of interwoven light and shadow, emphasizing the quiet atmosphere of an afternoon. Strive for the best possible result.
A publicly shared developer example used a code-only path tracer and several hours of offline rendering. Window-frame shadows stretched across walls, a chair, and a parquet floor, with natural transitions between illuminated and shaded areas. The result approached a photographic appearance.
When tested with the same prompt, a code-generation model took a different route: it built the room using a graphics API and also supplied a CPU rendering version. Angled light from the window passed across a small round stool and reached the lower edge of the scene, giving the image a clear sense of direction. However, the dark lines in the room’s corners were too harsh, the plant and floor looked like temporary set pieces, and the materials lacked depth.
These results point to two observations. First, the model understood concepts such as window-frame shadows, directional lighting, and light-to-dark transitions well enough to produce an executable rendering pipeline. Second, its control over materials, soft shadows, global illumination, and color management remained inconsistent.
When evaluating code-generated imagery, focus on the following:
- Is the light direction consistent throughout the scene?
- Do shadow edges vary with distance rather than remaining uniformly sharp?
- Do materials differ in roughness, reflection, and texture?
- Are highlights overexposed or shadows crushed to black?
- Does the composition have a clear focal point, rather than simply accumulating objects?
A maintainable rendering implementation typically separates scene description, sampling logic, and output:
scene = define_room()light = define_window_light()for pixel in image:ray = camera_ray(pixel)color = trace(ray, scene, light)color = tone_map(color)write(image)
Code that merely produces an image can still be expensive to improve. Without parameterized materials, sampling controls, and noise handling, subsequent optimization becomes difficult. Compared with the reference example, the gap is not simply code volume. It also involves visual judgment informed by graphics principles and physical consistency.
4. Why Coding Ability Does Not Guarantee Visual Quality
The two tasks support a common conclusion: models have made substantial progress in structured code generation, but visual judgment and physical realism remain less reliable.
In the SVG task, the model was effective at separating interaction into state and controls. In the rendering task, it could assemble a rendering framework but struggled with materials, soft shadows, tone mapping, and composition.
This is not necessarily a weakness of one particular model. It reflects a broader challenge in visual code generation: training signals tend to favor executable code, while a compelling image also requires graphics knowledge, photographic composition, and artistic judgment.
Developers should therefore avoid treating a successful demo as proof of production readiness. Model selection should not depend on screenshots alone.
5. Practical Evaluation for Engineering Teams
Build a small, stable evaluation set covering animation, charts, 3D scenes, data visualization, and interactive components. For each task, record executability, visual quality, maintenance effort, and performance.
Batch evaluations can run on general-purpose infrastructure such as container platforms, object storage, and logging services. Centralizing artifacts and logs helps reduce differences between execution environments.
Use a two-track acceptance process:
- Automated checks: Validate syntax, dependencies, payload size, and frame rate.
- Human review: Assess composition, lighting, and the completeness of interactive behavior.
For important tasks, retain the prompt, model reasoning setting, runtime environment, and exported artifacts so that results can be reproduced.
6. Conclusion
These tests suggest that structured visual code, such as animated SVG, is already reasonably usable, including interactive controls and standalone offline export. Code-based lighting and rendering reveal more persistent weaknesses in materials, soft shadows, and visual judgment.
A practical approach is to treat the model as a productive code scaffolding assistant, then close the remaining gap with explicit visual guidelines, rendering parameters, and acceptance criteria. Visual code generation becomes suitable for production only when evaluation moves beyond “it runs” to include visual quality, maintainability, and measurable performance.
