HACKER Q&A
📣 scotty79

What do you use for programmatic drawing?


When you need to write some program that calculates and shows something quick you probably write some console program in whatever language.

But what do you personally do, when you need a quick program that needs to draw some arbitrary graphics?

What languages and libraries do you use to draw something quick to see it, save it or animate it without a hassle?


  👤 susam Accepted Answer ✓
Gnuplot for graphs.

LaTeX PGF/TikZ for complicated diagrams.

Lines and boxes drawn with ASCII symbols (e.g., +, -, |, <, >, ^, v, /, \, ', `, etc.) using Emacs for very simple diagrams.

PGF/TikZ has considerable learning curve, so it may seem like a hassle in the initial days of learning to use it. But after mastering it once, one can unlock a lot of power and flexibility that comes with it. The PGF/TikZ manual at http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf is really worth seeing. This manual, which is itself designed using PGF/TikZ, is a masterpiece!


👤 kaycebasques
https://sequencediagram.org served my needs when I needed to create some timing diagrams for the Corrily docs (e.g. [1]). The cool thing about it is that I could save the source code of the diagram alongside the document itself (as a comment in the markdown).

[1] https://docs.corrily.com/docs/price-optimization-overview


👤 ai_ia
I usually use Manim for creating mathematical animations for some Mathematical courses I am writing. It’s a python library developed by the guy from 3b1b and it’s a joy to work with it.

👤 cpach
Have you tried Pic? It might suit your needs.

http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/web/pic.html


👤 dkersten
I've used pixijs.com in javascript, especially the drawing bits: https://pixijs.io/examples/#/graphics/simple.js You can export the drawn surface as an image. Not sure how if it will would work from a commandline program though.

👤 truly
I am using Manim for animations.

However, I am also on the lookout for a good programmatic graphics editor. I am thinking of developing my own, but time is an issue.

I have successfully also used Python libraries like this one to create some graphics:

https://pypi.org/project/svgwrite/


👤 tmaly
For Python you could use the pyglet OpenGL library to do both 2D and 3D https://github.com/pyglet/pyglet

For Scratch, the pen tool extension works really well. I was just doing a demo on this for an elementary class the other day.


👤 slopdo
I'm not using it but just in case it is useful to anybody here I would add Processing to the list. Lots of examples can be found at its website:

https://processing.org/examples


👤 zzo38computer
I use Ghostscript (although it doesn't do animations as far as I know, but it works for programmable drawings without animations).

👤 jiehong
P5.js[0] for animating stuff quickly.

[0]: https://p5js.org/


👤 dummy_physicist
Graphviz for diagrams, R standard library for plots, and imageMagick for simple image creation or processing.

👤 tomjen3
Javascript and canvas. You can just right click and save the image.