What are your favorite drawing libraries?

21 points by knl


To scratch an itch, I’m about to work on a layouting/diagraming tool like d2lang and Graph::Easy, but with a really narrow scope. So I’m looking for good libraries that would make it pleasurable to draw shapes and connecting lines (never did UI work in my life), with easy exporting to SVG. I’m curious to hear about your favorite, go-to libraries for these kinds of tasks, and what makes them special.

JulianWgs

TikZ all the way: https://texample.net/signpost/

Unfortunately I don‘t use it anymore, because I rarely need print quality diagrams. If there would be a job opening of creating TikZ figures all day I might think about applying although AI probably steals all the fun nowadays. D3.js is also nice, but I never really got the hang of it.

jjasghar

I've found https://mermaid.js.org/ do more or less all my heavy lifting now-a-days. It works on GitHub/Obsidian and makes it pretty enough for my boxes lines diagrams without too much overhead.

nmattia

Use SVG directly! It's a very small language supported by most OSs, browsers and editors. It has its quirks but it's super stable. If necessary you can always use imagemagick or any other tool to rasterize it.

apg

I’ve always been a fan of pict, which provides higher order operations for drawing and composition of pictures. As an example, you can call stuff like (beside x y) and it will create a new picture with x and y next to each other horizontally. For drawing diagrams, this model might be very helpful for you!

romforth

If you don't mind using an old school DSL there's PIC (and more recently, there's pikchr. They have been around forever and will probably run on any UNIXen with support for troff/groff and maybe even on Windows under WSL.

I'd written up a blog entry about it a while back (just skip the part that turned into a rant at ChatGPT and Google midway through the blog - since they can't seem to surface these tools anymore)

abetusk

two.js:

Two.js has warts but it's done the thing that I want it to do. Everything else either brings in a huge mental model with it or is more for specialized tasks that I'm trying to contort to do what I want. I've resigned myself to using "lower level" API calls to draw what I actually want.

For more interactive 2d work, I've used Pixi.js but this doesn't have good SVG export capability.

I've given up on 3d drawing libraries that export to SVG, not that that's a well defined problem to begin with.

natfu

The venerable https://plantuml.com/ has support for plenty of drawing DSLs.