How LLMs Paint Stroke by Stroke Without Image Generation Models

    This article explores an alternative to diffusion-based image generation: using code-oriented large language models to simulate a real brush and produce paintings stroke by stroke. It explains the four-stage observe–plan–execute–correct loop behind such systems, how bristle structure, pigment flow, path jitter, and stroke ordering create a realistic hand-painted look, and how the non-undoable nature of strokes can be turned into an engineering advantage. It also compares code-driven painting with traditional image generation across editability, reproducibility, cost, and failure modes, outlines which cloud building blocks can support such a pipeline, and offers practical guidance on evaluating fitness for a given use case.

    1. A Counterintuitive Approach: Generate Actions, Not Pixels

    When people think of large-model image creation, most picture diffusion models: the model iteratively denoises random noise in a latent space and outputs an entire pixel image in one pass. That route is mature, efficient, and its visual quality has been well validated by the market. But a direction worth attention recently bypasses image generation models entirely: a code-oriented LLM simulates a real paintbrush with a program and paints the picture one stroke at a time. It does not output pixels; it outputs “actions” — the position, angle, pressure, color, and water content of each stroke, written by the model as a runnable program. The image appears on the canvas only after the program executes.

    This route may sound like a step backward, but in fact it brings a completely different set of engineering properties: the picture is naturally layered, editable, and losslessly scalable; every stroke carries semantics (this is the third glaze of the sky, this is the outline of the bird’s back); and when something fails, it is “painted wrong” rather than “the generation collapsed,” so a new stroke can cover and correct it. Understanding these properties is more valuable than memorizing the name of any particular product.

    2. How the Stroke Engine Works: A Four-Step Loop

    Regardless of the specific implementation, the backbone of this class of system is highly consistent and can be abstracted as an observe–plan–execute–correct loop:

    1. # Illustrative pseudocode: stroke engine main loop
    2. canvas = Canvas(width=1200, height=800, texture="cold_press_paper")
    3. renderer = BrushEngine(canvas)
    4. for step in range(max_steps):
    5. # 1) Observe the current canvas state
    6. state = canvas.sample() # sample colors, edge density, tonal distribution
    7. # 2) Plan the next stroke: strategy comes from the LLM / a rule-based scheduler
    8. plan = planner.next_stroke(state, remaining_budget)
    9. # 3) Execute: apply the stroke to the canvas, non-undoable
    10. renderer.stroke(
    11. points=plan.points, # Bezier path + jitter perturbation
    12. color=plan.color, # e.g. #30346a
    13. width=plan.width, # e.g. 90 px
    14. opacity=plan.alpha, # coverage / opacity
    15. bristle=plan.bristle, # bristle stiffness, splitting, drag trails
    16. )
    17. # 4) Correct: if a deviation is found, add, cover, or highlight
    18. if renderer.needs_fix(state):
    19. plan.correct()

    Of the four stages, what really determines whether the result “looks hand-painted” is the physical simulation in step 3, while what determines whether the picture “resembles the target” is the planning quality and budget control in step 2.

    3. Brushes and Pigments: Encoding “Hand Tremor” and “Wetness” as Parameters

    Realism does not come from a more complex model but from modeling physical details. It can be broken down into four dimensions:

    1. Bristle structure. The bristles of a brush are not a uniform block of color but several bundles of hair with gaps between them. Rendering samples in parallel across the bristle count, with each bundle carrying slight differences in width and intensity, which naturally produces the dry-brush skipping and trailing drag effects.
    2. Water content and pigment rheology. Water content determines the diffusion radius of the pigment, whether water marks form at the edges, and whether the color is “eaten” by the canvas fibers. Coarse-textured watercolor paper absorbs quickly with little diffusion; fine-textured paper absorbs slowly and the color sits on the surface. Using “paper texture height map + water content” as boundary conditions gives color placement a plausibility within randomness.
    3. Path jitter. An absolutely straight line looks the most machine-made. A repeatedly validated technique is to add small random perturbations to path points — for example, adding roughly 7 px of lateral sway to a 90 px-wide stroke to mimic the physiological tremor of a human arm. The amplitude must scale with stroke width: thin lines jitter less, wide brushes jitter more, otherwise the result “looks fake enough to glow.”
    4. Stroke order and negative space. Lay down large areas of base color first, then build up layer after layer of glazes, and finally resolve outlines and highlights. This order matches the actual workflow of oil and watercolor painting, and it also lets the model manage complexity by “layering.”

    4. Turning “Painting” into an Orchestratable Engineering Workflow

    Once a picture is decomposed into hundreds of thousands of independent strokes, engineering problems emerge immediately: how the program is organized, how it is validated, and how to avoid “getting dirtier with every stroke.”

    • Program structure as layering. In practice, each painting program often runs to thousands of lines and is essentially a version-controllable “layer description.” It is advisable to write the base layer, glaze layer, detail layer, and highlight layer as separate functions, making rollback and local repainting easier.
    • The non-undoable constraint is actually an advantage. Once a stroke lands it is fixed; the model cannot “erase and start over” and can only correct by covering with new strokes. This forces the planning stage to think ahead and naturally avoids endless trial and error. If reversibility is required, you can take periodic snapshots of the canvas state and implement “undo” as a version rollback.
    • Self-checking. Across multiple rounds of painting, the model reads the canvas to perform geometric and color-scheme checks: whether outlines are closed, whether adjacent color blocks jump abruptly, and whether the subject’s proportions are distorted. When it finds issues like “the bird’s back is too thin and the lines are messy,” it uses added strokes to thicken them or overlays similar strokes to soften them, rather than rewriting the whole image.
    • Quality gates. You can introduce structured metrics for automated acceptance: edge contrast, hue distribution entropy, and coverage of the target region. If a metric falls short, it is fed back to the planner to reallocate the stroke budget.

    5. Three Cost Questions to Settle Before Enterprise Adoption

    This route is not “a more expensive toy.” It has clear use cases and a clear cost structure:

    Dimension Code-driven stroke-by-stroke painting Traditional image generation
    Output form Executable code + layered picture Single pixel image
    Editability Any stroke and any layer can be changed Requires repainting or local resampling
    Style consistency Stabilized through prompts and feedback Depends on model and sampling parameters
    Reproducibility Fully reproducible with code + random seed Affected by version and scheduling
    Main cost Inference calls, step count, storage Single inference, GPU memory
    Failure mode Structural deviation in the picture, messy strokes Collapsed structure, anatomical errors

    Therefore, when the business needs editable design drafts, reproducible visual assets, and an auditable generation process, the code-driven route has clear advantages; when it needs high concurrency, low cost, and fast output, the traditional route is more suitable. For most teams the real answer is a hybrid: first use a traditional model to quickly produce candidates, then use the code-driven route for refinement and structured repainting.

    If you want to run this kind of system on the cloud, what you reuse is general-purpose capability rather than some proprietary interface: use a container platform to deploy stateless stroke-rendering services and scale elastically per step; use object storage to keep canvas snapshots, stroke sequences, and finished images, naturally forming a version chain; use a message queue to decouple the “plan–render–inspect” three-stage pipeline so long-running tasks do not block each other; and use logging services and monitoring alerts to track step count, duration, and failure rate per artwork for capacity and cost forecasting. These are building blocks available in any cloud environment — the combination is what matters.

    6. From “Being Able to Paint” to “Having a Personal Style”

    An easily overlooked phenomenon: when the model is allowed to plan its own strokes instead of imitating an existing style, it actually settles into stable, personalized characteristics. The practical approach is to give the model a fictional artist persona — with its own experiences, preferences, and creative taboos — and then use textual feedback to guide it in adjusting brush parameters and painting engine settings. The persona provides constraints and the feedback provides the gradient; together they converge randomness into a “recognizable style.”

    This is also a technical response to the debate over style imitation: rather than having the model approximate a specific artist’s existing works, it is better to let it grow its own explainable set of parameter preferences and workflow habits.

    7. Capability Boundaries and Evaluation Recommendations

    It must be acknowledged objectively: this route has not yet reached stable photorealistic output, and its performance depends heavily on stroke budget and planning quality; in scenes requiring dense texture (fur, fabric, water reflections), the number of strokes rises sharply, and cost and time offer no advantage. At the same time, tuning the physical simulation parameters lacks a general theory and relies mostly on experience and repeated experimentation.

    To assess whether your own scenario fits, a three-step small-scale validation is recommended: first, given 20 reference images, measure the average stroke count and per-stroke time for the target style to project the upper bounds of cost and latency; second, construct five typical defect classes (broken outlines, color banding, proportion distortion, messy strokes, insufficient negative space) to test whether the self-checking and correction stages can converge; third, verify reproducibility by fixing the random seed and code version, confirm that the output is fully identical, and only then move into the production pipeline.

    Closing thought: the value of code-driven stroke-by-stroke painting is not to replace image generation models but to turn “generation” from a one-shot black box into an explainable, editable, and auditable process. For developers, understanding the physics of brushes, pigments, and canvas is more durable than chasing the parameters of any single tool.