Generating Images and Animations with Code: A Practical Framework for Evaluating Large Models

    Visual programming tasks provide a direct way to assess how well large models understand geometry, motion, lighting, and software structure. This article presents evaluation principles for SVG animation and programmatic rendering, including standardized prompts, fixed environments, repeated sampling, automated checks, human review, scoring dimensions, common failure modes, and recommendations for maintaining a long-term benchmark.

    1. Why Use Visual Tasks to Evaluate Coding Ability

    Code generation is often evaluated with algorithmic problems or unit tests. However, these metrics reveal little about a model’s understanding of space, time, and lighting. Visual tasks turn code output into an image or animation that can be inspected directly, allowing evaluators to quickly determine whether the result is reasonable.

    Visual tasks have two important characteristics:

    • The results are easy to inspect. Problems such as distorted proportions, intersecting objects, and broken lighting are usually visible immediately.
    • They test multiple capabilities at once. A model must produce syntactically correct code while also understanding geometric relationships, timelines, and visual rules.

    For these reasons, visual tasks can serve as a useful window into a model’s broader capabilities.

    A visually attractive result does not necessarily indicate strong engineering ability. Evaluation should distinguish among three levels:

    1. Whether the code runs.
    2. Whether the visual result is reasonable.
    3. Whether the implementation is maintainable.

    Each level should have its own evaluation criteria.

    2. Principles for Designing Evaluation Tasks

    A reliable evaluation should satisfy three conditions: standardized prompts, a fixed execution environment, and repeatable inspection.

    2.1 Standardize the Prompt

    Use the same prompt for the same task. Do not add extra instructions or modify the prompt based on the output.

    If multiple rounds of correction are required, record the number of revisions separately and distinguish those results from outputs that pass on the first attempt.

    2.2 Fix the Execution Environment

    Record the model version, request parameters, reasoning setting, and generation time. Rendering tasks should also record the execution platform and the browser or renderer version, because identical code may produce different visuals in different environments.

    2.3 Sample Multiple Times

    Model output is probabilistic. Run each prompt at least three to five times and evaluate the stability of the results. Keeping only the best output can significantly overestimate a model’s capabilities.

    3. Two Representative Task Categories

    3.1 Vector Animation: Describing Dynamic Scenes with SVG

    SVG is an XML-based vector graphics format. Its elements can be animated with SMIL, CSS animations, or scripts. Asking a model to generate an animated SVG can test its understanding of coordinate systems, paths, transformations, and timelines.

    Evaluation can cover the following areas:

    • Syntax validity: Can the file be read by a standard parser?
    • Independence: Does the file depend on external resources? If it references network URLs, the animation may fail when opened offline.
    • Animation logic: Are motion paths continuous? Are speed changes appropriate? Does the loop feel natural?
    • Interaction: If the task requires pausing, speed control, or state switching, verify each feature individually.

    The following script performs a basic structural check to determine whether an SVG is valid and whether it contains external references:

    1. import xml.etree.ElementTree as ET
    2. XLINK = "{http://www.w3.org/1999/xlink}href"
    3. def check_svg(path):
    4. try:
    5. root = ET.parse(path).getroot()
    6. except ET.ParseError as e:
    7. return {"valid": False, "error": str(e)}
    8. if not root.tag.endswith("svg"):
    9. return {"valid": False, "error": "The root element is not svg"}
    10. external = []
    11. for el in root.iter():
    12. for attr in ("href", XLINK):
    13. value = el.attrib.get(attr, "")
    14. if value.startswith(("http://", "https://")):
    15. external.append(value)
    16. return {"valid": True, "external_refs": external}

    This script checks structure only; it cannot determine whether an animation looks good. The animation must still be viewed manually, with keyframe behavior recorded during the review.

    3.2 Programmatic Rendering: Creating Lighting Scenes with Code

    Programmatic rendering requires the model to describe geometry, materials, and light sources in code. A renderer then produces the image. Three common approaches are:

    • Rasterization: Use a browser graphics API or a local graphics library to project triangles onto the screen. This is fast and suitable for interactive scenes, but shadows and indirect lighting require additional approximations.
    • Ray tracing: Implement a path tracer, often in C++ or another systems language, to simulate multiple light bounces. This can produce more physically credible images but requires more computation.
    • CPU software rendering: Calculate colors pixel by pixel without relying on graphics hardware. This is simple to implement and debug, but resolution and sample counts are limited.

    The costs and objectives of these approaches differ substantially, so their visual quality should not be compared directly. When comparing results, keep the subject and composition fixed, and focus on whether the lighting and structure are reasonable.

    Four areas are especially important when evaluating rendered images:

    1. Lighting continuity: Are transitions from light to dark natural, without obvious discontinuities?
    2. Shadow shape: Do shadow edges match the light-source position? Is the edge softness consistent with the size of the light source?
    3. Spatial proportions: Are the relationships among furniture, walls, and floors coherent? Is the perspective consistent?
    4. Material appearance: Are the highlights and roughness of materials such as wood, fabric, and ceramic visibly differentiated?

    The following script uses simple gradient statistics to help identify overly sharp edges. It is only a heuristic and cannot replace human judgment:

    1. import numpy as np
    2. from PIL import Image
    3. def edge_strength(path, percentile=99):
    4. gray = np.asarray(Image.open(path).convert("L"), dtype=float)
    5. gy, gx = np.gradient(gray)
    6. magnitude = np.hypot(gx, gy)
    7. return float(np.percentile(magnitude, percentile))
    8. def compare_edges(path_a, path_b):
    9. a, b = edge_strength(path_a), edge_strength(path_b)
    10. return {"a": a, "b": b, "sharper": "a" if a > b else "b"}

    A higher value usually indicates strong edges, which may result from sharply cut shadows or excessive fine lines. However, images with rich textures can also produce high values. The result must therefore be interpreted together with the image content.

    4. Evaluation Dimensions and Scoring

    To make reviews more consistent across evaluators, divide the assessment into fixed dimensions and define criteria for each one.

    Dimension Evaluation question Recording method
    Executability Can the code or file run directly? Pass or fail
    Feature completeness Are all prompt requirements implemented? Check each requirement
    Visual continuity Are lighting and motion natural? Score from one to five
    Structural plausibility Are spatial relationships and proportions correct? Score from one to five
    Code quality Is the structure clear and free of obvious redundancy? Manual inspection
    Reproducibility Are results stable across multiple runs? Calculate the consistency rate

    Start with executability and feature completeness. If a sample fails either of these checks, there is little value in comparing its visual quality further.

    5. Common Failure Modes

    The following problems occur frequently in practical evaluations:

    • Syntax errors: SVG tags are not closed, or JavaScript variables are undeclared, leaving the page blank.
    • External dependencies: The animation requires network-loaded scripts or fonts and fails when opened offline.
    • Lighting discontinuities: The light direction conflicts with the shadow direction, or shadow edges are excessively hard.
    • Incorrect proportions: Tables, chairs, or plants do not fit the room, making the scene look like an artificial set.
    • Mismatch between description and output: The accompanying explanation claims that an effect has been implemented, but the code contains no corresponding logic.

    The last issue deserves particular attention. Evaluators should rely on the code and the actual output rather than promotional descriptions.

    6. Engineering Recommendations

    Teams that need to track a model’s visual programming ability over time can consider the following practices:

    1. Build a benchmark set: Create 10 to 20 fixed tasks covering animation, static graphics, interactive interfaces, and physical simulation.
    2. Record versions and parameters: Save the model version, prompt, request parameters, and output files for every test so results can be traced later.
    3. Combine automated checks with human review: Use scripts to check syntax and file structure, while human reviewers assess visual quality.
    4. Compare rendering approaches separately: Different rendering pipelines have different costs and goals. They should be evaluated in separate groups rather than placed on a single leaderboard.
    5. Keep failure cases: Failed outputs often reveal a model’s weaknesses more clearly than successful examples.

    7. Conclusion and Limitations

    Visual programming tasks can provide an intuitive view of a model’s understanding of space, time, and lighting. However, their conclusions have clear limitations. A single sample cannot represent a model’s overall ability, and different prompts or execution environments can produce different results.

    Evaluation conclusions should therefore be based on standardized task sets, repeated sampling, and transparent scoring criteria. By documenting the testing process carefully, teams can determine whether a model is suitable for their own use cases and continue tracking its progress over time.