Abstract

esbozo is a tool I built to draw diagrams in a hand-drawn style, for people and for agents. A diagram is a Scene, a JSON file that the tool renders to an SVG that works in the light and the dark theme, and I embedded its editor in the Preview of this website.

I draw a lot of diagrams in my Zetts, and I want them to look hand drawn, in the same style as the rest of the website. That is what esbozo is. The agents that write my Drafts use it as well, so they can draw a diagram when a Zett needs one. You can find the code in its repository (opens in a new tab).

Please check the Glossary. The way I write Zetts with the agents is explained in this note.

Why I Built It ↑

I started with Excalidraw. I created a skill that turned the style of an Excalidraw diagram into the style I wanted, with the font I like and everything looking hand drawn. Then I wanted to edit the diagrams from Preview itself. The best option was to create my own tool that draws diagrams in the style I want, and to make it embeddable in any website. That way I could use it from the Preview of this blog, and that is what I have today.

The Scene ↑

A Scene is a .esbozo file that describes a diagram with elements such as rectangles, ellipses, arrows and text. The tool renders it to an SVG that takes its colors and its font from the page around it, so the same file works in the light and the dark theme.

In the following diagram, you can see the same Scene drawn in three styles. It is a square with an arrow that points to a circle. The first one is plain, the second one has emphasis through a thicker line and a grey fill, and the third one is muted, with dashed lines.

A square pointing with an arrow to a circle, drawn three times: plain, with emphasis through a thicker line and a grey fill, and muted with dashed lines SquareCircleplainSquareCircleemphasisSquareCirclemuted

How an Agent Draws ↑

An agent writes the Scene directly, because it is only text. The ez command checks it, renders it and shows the result as a PNG, so the agent can look at its own work before it keeps it. The loop goes from the Scene to the SVG, and back to the Scene whenever something looks wrong.

The drawing loop: write the Scene, check it, look at the result, and render the SVG, going back to the Scene to fix whatever looks wrong 1. Write2. Check3. Look4. Renderez checkez pngez renderfix what looks wrongThe Drawing Loop

The Scene Is the Source ↑

The SVG is only an output. The Scene is the source, and the SVG carries a fingerprint of the Scene it was rendered from. When a diagram needs a change, I edit the Scene and render it again, and anything that holds both files can tell if they still match.

In This Blog ↑

The editor is a web component, so any page can embed it. I embedded it in the Preview of this website, and I can open a diagram there, draw it, and see it change in the Page right away. The website then uses the SVG that the tool wrote.

Glossary ↑