Eev and (My)QdrawMy main page on Maxima is here.
0. IntroductionThe animations below were created with MyQdraw: Creating animations with MyQdraw is not hard - see
this section.
I also use MyQdraw to LaTeXify Maxima logs with images - but the interface for that is very weird. See here. 1. Maxima by ExampleOne of the best places for learning Maxima from examples is a (free) book whose name is - ta-daaa! - Maxima by Example. It is divided into chapters, and my script to download a local copy of it is here. Its chapter 13 is about Qdraw, that is a front-end to Maxima's draw2d command (see also the Maxima Workbook). This page is about my current extensions to Qdraw. I'm calling my extensions "MyQdraw" - a bad name, chosen on purpose to indicate that this is not a mature package. 2. The "load"sThe examples in this page will suppose that you have downloaded myqdraw from its git repository, with something like this:
and that you have two lines like these ones in your init file:
I use the definitions below - see here:
3. EmacsI will also suppose that you have eev installed - see this page - and that you have a `code-c-d' that makes `find-myqdraw' point to the right place, like this:
At this moment all the people who are testing MyQdraw have installed it using this:
4. The core of MyQdrawInitially "myqdraw" was just this one-liner:
Here's why. The program below produces these two images: Its call to `qdraw' produces the image at the left and its call to `myqdraw' produces the image at the right. Here is the code:
The `qdraw' in it is called - and it needs to be called - with all its drawing commands "at the same level", but `myqdraw' flattens its list of drawing commands and then passes the flattened version to qdraw. The qdraw and the myqdraw above are called like this:
For complex drawings I found `myqdraw' much easier to use. After a while I saw that it would be good karma to also include some debugging functions. `qdraw' is a kind of preprocessor - first it calls `qdraw1' to transform its drawing commands into a list of drawing commands in the syntax of `draw2d', and then it calls `draw2d'. In this program
the `qdraw' just draws a circle, and the `qdraw1' doesn't draw anything, it just returns this list of drawing commands for `draw2d':
and the `qdraw1v' - a function that I defined - returns that list of drawing commands for `draw2d' "formatted vertically", like this:
4.1. Eight functionsSo, qdraw.mac defines these two main functions:
Let me invent some new verbs:
This part of myqdraw-core.mac complement those two functions with six new ones to build this cube,
where:
4.2. The rest of the core5. Generating PDFsThis module
defines a variant of `myqdraw' called `myqdrawp', that can be configured to work in three modes. The command
makes `myqdrawp' be equivalent to `myqdraw'; the command
is not very interesting, so I won't explain it now, and
makes each call to `myqdrawp' draw into a new PDF instead of drawing on the screen. This mode is to generate animations, as explained in the next section, and by my variant of emaxima.sty - see here. 5.1. AnimationsIn all the (few!) cases in which I wanted to produce animations with Maxima my animations were always just teasers for something else... for example, this animation is a teaser for this flipbook. I needed a way to make all frames of my animations accessible in high resolution, and I needed to let people move back and forth easily between the frames with an adjustable speed - and the easiest way to do that was by generating flipbooks in PDF. The animation loads immediately, and jumps in your face; accessing the PDF takes some clicks, some seconds, and some patience. Maxima comes with several ways to create animated gifs. We can use:
...but it was easy to adapt MyQdraw to make it produce a series of frames and then glue them into a flipbook, so I did that. One of the files that myqdraw3.mac loads is topdf1.mac, and topdf1.mac ends with a test block called "quick-demo", that has a part that starts with
that produces the frames, and a part that starts with
that produces the flipbook and the animated gif. Here's what we see after running the first part: Note this part of the log:
If we just press a series of <f8>s the "myqdrawp_to_new_pdf()" overrides the "myqdrawp_to_screen()", and each one of these `myqdrawp's
saves a new PDF to disk; but if we had skipped the "myqdrawp_to_new_pdf()" by typing a <down> on its line instead of an <f8>, then each one of the `myqdrawp's above would draw to the screen - instead of creating a PDF. The second part, whose core is:
is explained here. Lines that start with "**" are treated by <f8> as comments; some of them contain ways to inspect the flipbook or the animated git, but to execute them we need `M-e' or `M-x brg'. |