AI Art Without Image Models: Simulating Brush Strokes in Code

    This article explores an alternative approach to AI image generation that skips diffusion and image models entirely: a coding model writes an executable drawing program that paints stroke by stroke on a virtual canvas. It breaks down a four-layer architecture (Planner, Stroke DSL, Renderer, Critic), the physical modeling behind realistic brushwork, multi-round feedback loops, externalized style profiles, cost control, quality metrics, and common pitfalls, showing how the problem shifts from generating pixels to writing a render program that is auditable, interruptible, and reusable.

    1. The Starting Point: Why “No Image Model” Is Worth Studying

    Most mainstream AI image generation today is built on diffusion models: the model iteratively denoises in a latent space, turning random noise back into a pixel matrix, and a single inference pass produces the finished image. This path is end-to-end and fast, but the process is an uninterpretable black box. Users can only accept or reject the result; they cannot intervene and say “the third stroke was wrong.”

    The approach described in the source material does the opposite. The model does not output pixels directly. Instead, it writes an executable drawing program that simulates the motion of a real brush on a virtual canvas, completing the work stroke by stroke. It can even emulate brush texture, paint wetness, and canvas grain, and when it detects a deviation it covers and corrects it with new strokes. The core shift here is turning “generate an image” into “write a rendering program.”

    For developers, this idea has three direct benefits:

    • Auditable process: every stroke is a readable instruction, so errors can be located and replayed.
    • Interruptible results: parameters can be changed, strokes inserted, or styles switched at any stage.
    • Reusable capability: the drawing engine is decoupled from the model, so the engine can be tested and optimized independently.

    2. Overall Architecture: A Four-Layer Code-Driven Drawing System

    To engineer this idea, split it into four layers that communicate through explicit data contracts.

    1. Planner: a coding model decomposes “what to draw” into stage goals, such as composition, underpainting, subject, details, and finishing, then emits a stroke plan.
    2. Stroke DSL: defines a unified stroke instruction structure. Every drawing action must be serialized into coordinates and parameters; writing pixels directly is not allowed.
    3. Renderer: interprets stroke instructions and simulates brush shape, paint transfer, wet blending, and canvas texture to produce the canvas state.
    4. Critic: performs a visual check on the current canvas, outputs a problem description in natural language or structured form, and feeds it back to the Planner for the next correction round.

    A sketch of the stroke data structure:

    1. from dataclasses import dataclass, field
    2. @dataclass
    3. class Stroke:
    4. color: str # Hex color code, e.g. "#30346a"
    5. width: int # Brush width (pixels)
    6. points: list = field(default_factory=list) # Path control points
    7. jitter: float = 0.0 # Deliberately added jitter
    8. wetness: float = 0.5 # Paint wetness, affects edges and blending
    9. opacity: float = 1.0

    One point deserves emphasis: once a stroke is laid down it cannot be undone. This is the key constraint of the paradigm. It raises trial and error from the pixel level to the planning level, forcing the model to think before it commits.

    3. Physical Modeling of Strokes: Where Realism Comes From

    Realism does not come from high resolution; it comes from imperfection. The source material notes one detail: the model deliberately gives lines about 7 pixels of wobble, on the grounds that a human arm cannot draw a perfectly straight line either. This suggests the renderer should model at least three physical factors.

    • Brush texture: use a pressure curve that varies along the path to control width, plus a little noise so edges show burrs and dry breaks.
    • Paint wetness: when wet, paint bleeds toward the edges and mixes with the underlayer; when dry, coverage is strong and boundaries are crisp.
    • Canvas grain: pre-generate a texture field so paint deposition varies with the surface, avoiding a “plastic” flat look.
    1. def render_stroke(canvas, s: Stroke):
    2. for i in range(len(s.points) - 1):
    3. p0, p1 = s.points[i], s.points[i + 1]
    4. pressure = 1.0 - 0.3 * (i / max(1, len(s.points) - 1))
    5. w = s.width * pressure
    6. canvas.draw_segment(
    7. p0, p1,
    8. color=s.color,
    9. width=w,
    10. wetness=s.wetness,
    11. opacity=s.opacity,
    12. texture=canvas.texture_field, # Canvas texture field
    13. )

    A practical engineering recommendation: make the renderer a replaceable backend. Start with lightweight rasterization to keep iteration fast, then progressively swap in something closer to real paint simulation, so you do not burn early time on rendering performance.

    4. Multi-Round Feedback: Letting the Model Look at the Canvas and Revise

    The biggest problem with one-way generation is that errors accumulate. A workable approach is to make the feedback loop an explicit loop that allows only a limited number of correction strokes per round, preventing endless patching that muddies the image.

    1. for round_id in range(MAX_ROUNDS):
    2. plan = planner.next_plan(canvas.summary(), critic_report)
    3. for s in plan.strokes:
    4. canvas.apply(Stroke(**s)) # Strokes cannot be undone
    5. critic_report = critic.inspect(canvas) # e.g. subject outline too thin, lines messy
    6. if critic_report.is_satisfied():
    7. break

    Critic prompts should be specific and actionable, for example “the outline of the bird’s back is too thin; add two strokes with a wider brush along the original path,” rather than “this looks bad.” Such structured descriptions significantly improve the hit rate of corrections and make regression testing easier.

    5. Style and “Artistic Personality”: Avoiding Style Imitation

    The source material notes that early works were criticized for over-imitating existing artistic styles. The fix was to have the model define an “artist persona” with a fictional background and stable creative tendencies, then adjust brush and engine parameters through text feedback based on the results. In engineering terms, this externalizes style as a readable configuration instead of leaving it implicit in weights.

    1. artist_profile:
    2. palette: [low-saturation blue-green, warm gray, a little orange-red]
    3. stroke_style: medium-wide brush, low jitter, dry edges
    4. habits: [avoid straight lines, leave highlights unpainted, layer shadows multiple times]

    The benefits: style becomes versionable, comparable, and rollback-able, and it is easier to explain to stakeholders why a given painting has the character it does.

    6. Performance and Cost Control

    Stroke-by-stroke simulation means far more model calls and render passes than a single image inference, so cost strategy must be designed up front:

    • Layered precision: use large brushes and fewer strokes for the background, then raise density locally on the subject, instead of piling material evenly across the whole canvas.
    • Batched submission: merge the strokes of one stage into a single program execution to cut round-trip overhead.
    • Cache the texture field: generate canvas texture and brush shapes once and reuse them across the whole run.
    • Early stopping: stop as soon as the Critic is satisfied, with dual thresholds on maximum rounds and maximum strokes.
    • Asynchronous rendering: run rendering and planning in parallel, with the Planner waiting on a canvas summary rather than the full image.

    To run at scale, put canvas state and stroke logs in object storage, hand task scheduling to a container platform and message queue, and track per-round latency and failure rates with logging and monitoring alerts. These are general cloud capabilities, which makes horizontal scaling and debugging easier.

    7. Quality Evaluation: How to Tell Whether It “Looks Right”

    Build three layers of metrics instead of relying on subjective impression alone:

    1. Structure: whether subject position, proportion, and outline completeness meet the bar.
    2. Texture: whether edges have plausible burrs, whether color transitions are natural, and whether there are obvious repeated textures.
    3. Process: average correction rounds, wasted-stroke ratio, total strokes per image, and time spent.

    Process metrics matter especially, because they reflect planning quality directly. If the wasted-stroke ratio stays high over time, the Planner does not understand the renderer’s constraints well enough; improve prompts and constraint expression first rather than blindly adding rounds.

    8. Implementation Advice and Common Pitfalls

    • Build a minimal loop with a single color and a single brush first, get planning, rendering, and feedback working end to end, then expand brush types.
    • Strictly forbid the “shortcut” of writing pixels directly, or the system degenerates into ordinary image generation and loses interpretability.
    • Keep jitter and wetness within controlled ranges: too large makes the image noisy, too small loses the hand-drawn feel.
    • Retain a complete stroke log for every drawing, which helps with reproduction and teaching demos.
    • Be clear about the boundary: this paradigm suits scenarios that need process control and stable style; it does not suit high-volume generation chasing extremely low latency.

    9. Conclusion

    Drawing stroke by stroke in code without calling an image model is essentially a reframing of the problem: replacing uncontrollable pixel generation with controllable program execution. What it brings is not just another visual style but an engineering paradigm that is auditable, interruptible, and reusable. For teams that want to keep control over the process in generative applications, this route is worth putting on the technology selection list as an independent capability that complements end-to-end generation.