LLM Code-Driven Drawing: How Fable 5.2 Simulates Brushstrokes Without an Image Model

    This article explains how a large language model can create images by writing Python code that simulates physical brush movements instead of calling a diffusion-based image model. Using Fable 5.2 as an example, it breaks down the shift from pixel generation to code-driven painting, the physics modeling behind brushes and wet paint, the irreversibility constraint, the visual feedback loop, and the artist-persona approach to style control. It also outlines the cloud infrastructure components needed to run this kind of workload in production.

    Generating code that simulates the physical motion of a brush is a breakthrough paradigm that lets large language models bypass traditional diffusion models and paint complex images stroke by stroke on a virtual canvas. In November 2025, Fable 5.2, a programming and research model from a cloud vendor, demonstrated this non-conventional image generation capability, known as “code-driven drawing.” Unlike traditional image generation tools that output a pixel matrix directly, the model simulates the interaction between real brushes, paint, and canvas to produce photorealistic results. This approach reveals the potential of combining natural language processing with computer graphics, and it offers a new technical perspective for intelligent content production and design assistance.

    From Diffusion Models to Code-Driven Drawing: A Fundamental Shift

    Most mainstream AI image generation tools today rely on diffusion models. A diffusion model removes random noise step by step through a neural network to reconstruct a target image in latent space. This method can efficiently produce visually rich textures, but the underlying process is a black-box pixel generation routine. Users cannot intervene in individual drawing steps, and the output is highly nondeterministic.

    Fable 5.2 takes a completely different approach. It breaks the drawing process into a large number of independent, executable brushstroke instructions. Instead of generating an image directly, the model writes a specific Python program. On the virtual canvas, it treats painting as a temporal control problem, using code to precisely control the brush’s trajectory, tilt angle, applied pressure, and other physical properties.

    According to a technical demonstration, a seemingly simple piece can be backed by a Python program of 1,000 to 2,000 lines. The program calls a painting simulation engine to drive different types of brushes. In one example, rendering a high-precision image of shopping carts in a parking lot required roughly 700,000 independent simulated strokes. This “reason step by step, execute stroke by stroke” mode turns AI image generation from artistic expression into engineering construction, giving developers control over the entire pipeline from overall composition to individual strokes.

    Core Technical Breakdown: Physics Simulation and Iterative Correction

    Understanding how the model paints through code requires a closer look at the technical details. The process depends on fine-grained physics modeling, the ability to observe the real world, and a dynamic correction mechanism.

    1. Microscopic Modeling of Brushes and Canvas

    In a code-driven painting engine, a brush is no longer a simple drawing tool but a virtual object with complex physical properties. The model has to simulate a range of real-world variables:

    • Brush texture and material: Different brushes, such as soft-hair brushes, stiff bristle brushes, and dry brushes, have different ink absorption and diffusion characteristics.
    • Paint wetness: This is a critical parameter. Wet paint bleeds naturally when it touches the canvas, and lines gradually dry as moisture evaporates. By adjusting the wetness parameter in code, the model achieves layering similar to watercolor or oil painting.
    • Path smoothing and human-like jitter: In a sunrise scene experiment, the model was asked to draw a bird. To make the result feel more lifelike, it did not output a mathematically straight curve. The first line contained five slightly shifting path points, and an intentional wobble of about 7 pixels was used to mimic the natural physiological tremor of a human arm and remove any mechanical feel.

    2. Irreversibility Constraint on Strokes

    To keep the process close to real painting, the experiment imposed a strict rule: once a stroke lands on the canvas, it cannot be undone. The model must complete sufficient logical reasoning and spatial imagination before outputting the coordinates for each stroke.

    In the sunrise bird example, the model finished the entire piece in only 111 strokes. The first stroke used color #30346a (deep blue-purple) with a brush width of 90 pixels. During drawing, the model had to predict the coverage of every pixel and the final result of color blending, which places heavy demands on the model’s multimodal spatial understanding.

    3. Visual Feedback and Dynamic Correction

    Code generation is not a one-shot process. It uses a multi-round closed-loop adjustment mechanism. After outputting part of the stroke code, the model renders an intermediate image and uses visual perception to inspect the current state.

    • Defect identification: While drawing the bird, the model noticed that the lines on its back were too thin and that stray, ineffective strokes surrounded it.
    • Strategy adjustment: Based on textual critique, the model did not undo anything. Instead, it covered, thickened, or redrew areas with new strokes. For the back, for example, it could apply paint with higher wetness and use its blending properties to naturally hide the earlier flaws and smooth the transition.

    Building an Artistic Persona: Exploring an Independent AI Aesthetic

    AI-generated images are often criticized for lacking a soul or for merely imitating existing masters. To address this, the developers of Fable 5.2 introduced a strategy called the “artist style persona.”

    In earlier iterations, because the training data contained a large amount of existing artwork, the output occasionally imitated a specific artist too closely and drew criticism. In response, the developers designed a mechanism that lets Fable 5.2 create an artist persona with a “fictional background” and a “stable creative style.”

    The developers did not tell the model what to draw. Instead, they used textual feedback to guide it in adjusting the brush’s physical parameters and the underlying logic of the painting engine. For instance, if a version of the bird looked too sharp, the developer might say, “You need to convey more of the softness of early morning.” The model would then adjust the brush’s diffusion radius, lower the paint’s contrast, and even change the order in which strokes were layered. Controlling physics simulation parameters through language instructions is effectively a form of AI aesthetic alignment and style fine-tuning. Over time, the model developed a distinctive visual language, and its work showed a new texture that goes beyond the collage-like feel of traditional diffusion models.

    Engineering Practice and Cloud Enablement

    Code-driven drawing demonstrates strong potential, but its computational complexity is high. Simulating hundreds of thousands of strokes demands substantial compute, along with an efficient architecture to manage state changes and file I/O.

    To deploy similar AI creative tools in production, developers and enterprises need solid cloud infrastructure. In the Baidu AI Cloud ecosystem, this type of scenario typically involves the following core components:

    1. High-performance computing and container services: Because the process involves writing and running large amounts of Python rendering code, a container platform such as CCE can provide elastic compute scheduling. Containerized deployment keeps the painting engine stable under different concurrency levels.
    2. Object storage and content delivery: High-resolution artwork can be large. Object storage such as BOS can hold the generated source code, intermediate renders, and final outputs securely and at low cost. Paired with a content delivery network (CDN), it can deliver images within seconds.
    3. Monitoring, alerting, and observability: Since the painting process is a black-box code execution, a syntax error or infinite loop can crash the service. Cloud monitoring (BCM) and log services (BLS) can track code execution time and render failure rates in real time, and alerting policies can notify operations staff to intervene promptly.

    Summary and Outlook

    Having a large language model write Python code that simulates a brush moving across a canvas, rather than calling an image generation model, breaks the boundary of traditional AI image generation. It shows that LLMs have potential beyond pixel generation when it comes to complex spatial logic, physics simulation, and multi-step reasoning.

    Through brush texture modeling, wet paint simulation, human-like jitter algorithms, and an irreversible stroke correction mechanism, AI is gradually mastering painting, an activity once considered uniquely human. As code execution efficiency improves and multimodal capabilities grow, code-driven creation could add more value in digital art, game art, industrial design, and personalized education. For enterprises, combining the elastic compute and full-chain tooling of a cloud platform with specialized engines such as physics simulation and rendering engines will be key to bringing the next generation of intelligent applications to market.