Claude Code drew an entire 250-page book with code: 13 worlds and 53 character poses
A developer who can't draw asked Claude Code to illustrate his book about AI agents, and instead of ready-made PNGs, the agent wrote Python code that renders SVG. In the 250-page book, each chapter has its own world, 13 in total, from a kitchen to a space station, and five characters strike 53 poses between them. The PDF builds in roughly a minute. The takeaway: an agent can draw with code if you set strict rules for vector output in advance.
AI-processed from Habr AI; edited by Hamidun News
Asking a neural network to "draw a picture" and getting a PNG back has long been routine. The author of this story took a different route. He is a developer who can't draw, and for his book about preparing a repository and development process for work with an AI agent, he wanted illustrations in the style of the children's Professor Fortran's Encyclopedia.
Claude Code, running on the Opus 5.5 model (as the author states), proposed writing code instead of producing a ready-made raster. As a result, every drawing in the 250-page book is a Python function that assembles SVG.
In total there are 13 thematic worlds and 53 poses for five characters, and the whole book builds into a PDF in about a minute.
How a book drawn with code is structured
The book has 11 chapters, plus an introduction and a conclusion. Each chapter opens with a full-page cover, every text page ends with a strip 34 or 55 mm high, and the last page of each chapter is taken up by a large panorama.
At first the agent produced about five standard pictures for the bottom of the page, and by the second chapter they had become tiresome. The author's wife then suggested giving each chapter its own world with its own set of objects. The agent came up with the worlds itself: kitchen, fair, space station, library, attic, underwater base, laboratory, harbor with a lighthouse, lunar base, forest camp, railway, professor's courtyard, and a computer city.
Within each world there are stations, places where a single action from the chapter's text takes place. In the first chapter, about "slop" from agents, in the kitchen the professor pins a recipe to the board (this is the task), the agent takes a jar of copy-paste off the bottom shelf, the pie comes out burnt, and then the professor hangs the AGENTS.md rules on the fridge, and the agent bakes an even pie. The pictures at the bottom of the pages run left to right like frames of one film.
Technically it is simple: each picture is a function that returns an SVG string, the book is laid out as an ordinary HTML page, and Chrome prints it to PDF.
Where the agent ran into trouble
The first constraint came from phones. The book displayed badly in Telegram: when printing, Chrome converts a gradient-to-transparency into a 72 dpi raster, and Apple's PDF viewers show it as jagged. Now the code follows a rule: no masks, filters, or gradients-to-transparency; everything must stay vector. If the builder finds a stray raster image, it issues a warning, and in strict mode it stops with an error. The smooth fade of the sky above the characters is built by the agent from several dozen rectangles in the background color with ordinary flat transparency.
The second constraint was image weight. In the railway world, the gravel made of thousands of small stones and the brick platform made the drawings so heavy that Chrome began crashing from lack of memory when rendering pages. The agent stopped drawing each stone as a separate shape: all stones of one shade are now described by a single path element. After that, each railway frame weighed less than 200 KB. The same technique works for print hatching: a dot is a zero-length line with round caps, and thousands of such dots fit into a single contour.
The "hand-drawn" effect relies not on wobbling lines, as is usual, but on a thick ink outline and two-tone fill. First the silhouette is filled with a dark color, then a lighter silhouette shifted toward the light is drawn on top, and everything extra is clipped away. What remains is a narrow shadow, a cel-shading technique.
Poses turned out to be the hardest part. While the characters face the viewer, the agent draws them very well. But the professor seated at a table came out with legs in profile and torso frontal, as if he had been twisted 90 degrees at the waist. To let the characters be turned, each one needed at least two skeletons: a frontal one for standing and gestures, and a profile one for walking and sitting.
What to take from this in practice
Each character is a separate module with its own canvas size, floor line, height relative to the professor (426 abstract units), and a set of poses, from eight for Sparrow to twelve for the agent. The rest of the code does not check characters by name, so adding a sixth character requires only a new module and one line in the list.
The lesson for anyone working with agents: they can draw with code, provided the task has formal boundaries. Hard rules ("vector only"), builder warnings, and file-size limits work better than endless "fix this here" messages in chat. The weak spot is non-standard angles: seated, side, and especially back views require separate work.
- Nov 21, 202622 Claude Agents Spent Six Weeks on Black Hole Problems — and Solved Two
- Nov 21, 2026Google to split Gemini chat history from model training, so you can opt out without losing your history
- Nov 21, 2026Anthropic Goes Public: Up to $64.4B Raise, Ticker ANT, Listing November 19
- Nov 21, 2026Telegram Patches HTML Widget Holes as QuickJS Audit Finds 27 Bugs
Key Questions Answered
How a book drawn with code is structured?
The book has 11 chapters, plus an introduction and a conclusion. Each chapter opens with a full-page cover, every text page ends with a strip 34 or 55 mm high, and the last page of each chapter is taken up by a large panorama. At first the agent produced about five standard pictures for the bottom of the page, and by the second chapter they had become tiresome. The author's wife then suggested giving each chapter its own world with its own set of objects.
Where the agent ran into trouble?
The first constraint came from phones. The book displayed badly in Telegram: when printing, Chrome converts a gradient-to-transparency into a 72 dpi raster, and Apple's PDF viewers show it as jagged. Now the code follows a rule: no masks, filters, or gradients-to-transparency; everything must stay vector. If the builder finds a stray raster image, it issues a warning, and in strict mode it stops with an error.
What to take from this in practice?
Each character is a separate module with its own canvas size, floor line, height relative to the professor (426 abstract units), and a set of poses, from eight for Sparrow to twelve for the agent. The rest of the code does not check characters by name, so adding a sixth character requires only a new module and one line in the list. The lesson for anyone working with agents: they can draw with code, provided the task has formal boundaries.
Build & Ship Production AI Agents Without Boilerplate Code
Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.