Postscript is more than an just a vector image file format, it is a programming language. As a programming language, it may be exploited to great advantage for mathematical illustrations. This repository has a few examples.
You can read a bit more about these examples on my home page.
Have fun!
-mitch