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.
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 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 ↑
- Zett: A note I write myself, based on Transcripts, that ends up being the content of this blog.
- Transcript: A Nomad Note converted to a Markdown file.
- Scene: The
.esbozofile that describes one diagram. - Preview: The private version of the website, where I check a Draft before anything goes live.
- Draft: A Zett written by the agent in my Voice that I have not checked yet.
- Page: A Zett converted into HTML. A web page.