Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/topdf1.mac.html
 *   http://anggtwu.net/MAXIMA/topdf1.mac
 *          (find-angg "MAXIMA/topdf1.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 * Version: 2024oct15
 * Public domain.
 *
 * This file creates a variant of `qdraw' called `myqdraw',
 * that is simply "a qdraw that wraps its arguments", and
 * a variant of `myqdraw' called `myqdrawp', that can be
 * configured to work in three modes:
 *
 *   myqdrawp_to_screen()      makes myqdrawp draw to the screen,
 *   myqdrawp_to_single_pdf()  makes myqdrawp always draw into the same PDF,
 *   myqdrawp_to_new_pdf()     makes each myqdrawp draw into a new PDF.
 *
 * See: http://anggtwu.net/eev-maxima.html
 *      (find-windows-beginner-intro "12. Install qdraw")
 *      (find-angg ".maxima/maxima-init.mac" "load_qdraw")
 *      (find-angg "MAXIMA/mkanim1.sh")
 *
 * «.topdf-modes»		(to "topdf-modes")
 * «.topdf-modes-test»		(to "topdf-modes-test")
 * «.myqdrawp-modes»		(to "myqdrawp-modes")
 * «.myqdrawp-modes-test»	(to "myqdrawp-modes-test")
 * «.big-demo»			(to "big-demo")
 *   «.anim-make-each-frame»	(to "anim-make-each-frame")
 *   «.anim-make-frames.pdf»	(to "anim-make-frames.pdf")
 *   «.anim-make-frames.gif»	(to "anim-make-frames.gif")
 * «.quick-demo»		(to "quick-demo")
*/

topdf_a : "~/LATEX/";
topdf_b : "2024-1-C3/";
topdf_c : "test";
topdf_n : 0;
topdf_n_incr() := (topdf_n : topdf_n + 1);
topdf_c_cn  () := format("~a_~3,'0d", topdf_c, topdf_n);
topdf_c     () := topdf_c;       /* or: */
topdf_c     () := topdf_c_cn();
topdf_abc   () := format("~a~a~a", topdf_a, topdf_b, topdf_c());
topdf_bcpdf () := format("~a~a.pdf",        topdf_b, topdf_c());

topdf_opts : "height=5cm";
topdf_terminalpdf    () := more(terminal=pdf, file_name=topdf_abc());
topdf_includegraphics() := format("\\includegraphics[~a]{~a}",
                                  topdf_opts, topdf_bcpdf());


/* «topdf-modes»  (to ".topdf-modes")
 * topdf() can run one of these three functions:
 *   topdf_to_screen()      -- draw to screen,
 *   topdf_to_single_pdf()  -- save to foo.pdf,
 *   topdf_to_new_pdf()     -- save to foo_<nnn>.pdf,
*/
topdf_to_screen    () := [];
topdf_to_single_pdf() := [(topdf_c() := topdf_c,
                           topdf_terminalpdf())];
topdf_to_new_pdf   () := [(topdf_c() := topdf_c_cn(),
                           topdf_n_incr(),
                           topdf_terminalpdf())];

topdf              () := topdf_to_screen();   /* default */

/* «topdf-modes-test»  (to ".topdf-modes-test")
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("topdf1.mac");
topdf_abc();
topdf_bcpdf();

topdf() := topdf_to_screen();
topdf();

topdf_c : "test-single";
topdf() := topdf_to_single_pdf();
topdf();

topdf_c : "test";
topdf() := topdf_to_new_pdf();
topdf();
topdf();
topdf_includegraphics();
topdf_n : 0;
topdf();

*/



/* «myqdrawp-modes»  (to ".myqdrawp-modes")
 * `myqdraw'  is like   `qdraw', but it flattens its list of arguments.
 * `myqdrawp' is like `myqdraw', but it can be in any of three modes.
 *
 * Here's how to select the modes:
 *   myqdrawp_to_screen()      -- makes myqdrawp draw to the screen,
 *   myqdrawp_to_single_pdf()  -- makes myqdrawp always draw into the same PDF,
 *   myqdrawp_to_new_pdf()     -- makes each myqdrawp draw into a new PDF.
*/

myqdraw    ([qargs]) := apply('qdraw, flatten([qargs]));

myqdrawp_1 ([qargs]) :=  myqdraw(qargs);
myqdrawp_2 ([qargs]) :=  myqdraw(topdf(), qargs);
myqdrawp_3 ([qargs]) := (myqdraw(topdf(), qargs), topdf_includegraphics());

myqdrawp_to_screen()     := (topdf() := topdf_to_screen(),
                             myqdrawp([qargs]) := myqdrawp_2(qargs),
                             "Will draw to the screen.");
myqdrawp_to_single_pdf() := (topdf() := topdf_to_single_pdf(),
                             myqdrawp([qargs]) := myqdrawp_3(qargs),
                             "Will always draw to the same PDF.");
myqdrawp_to_new_pdf()    := (topdf() := topdf_to_new_pdf(),
                             myqdrawp([qargs]) := myqdrawp_3(qargs),
                             "Will always draw to a new PDF.");

myqdrawp_to_screen();   /* default */


/* «myqdrawp-modes-test»  (to ".myqdrawp-modes-test")
*
* (find-sh0 "ls -lAF /tmp/frame*")
* (find-sh0 "rm   -v /tmp/frame*")
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/topdf1.mac")
load       ("~/MAXIMA/topdf1.mac");
load_qdraw();

myxyrange()  := [xr(-2,5),yr(-2,3),more(proportional_axes=xy)];
drawing1(Dx) := para(cos(t)+Dx,sin(t), t,0,2*%pi);
drawing (Dx) := [myxyrange(), drawing1(Dx)];

myqdrawp_to_screen();
myqdrawp(drawing(0));

[topdf_a,topdf_b,topdf_c] : ["/tmp/", "", "frame"];
myqdrawp_to_single_pdf();
myqdrawp(drawing(0.0));
myqdrawp(drawing(0.5));

myqdrawp_to_new_pdf();
myqdrawp(drawing(1.0));
myqdrawp(drawing(1.5));
**
** Inspect:
** (find-fline "/tmp/" "frame_")

*/



/*  ____  _             _                      
 * | __ )(_) __ _    __| | ___ _ __ ___   ___  
 * |  _ \| |/ _` |  / _` |/ _ \ '_ ` _ \ / _ \ 
 * | |_) | | (_| | | (_| |  __/ | | | | | (_) |
 * |____/|_|\__, |  \__,_|\___|_| |_| |_|\___/ 
 *          |___/                              
 *
 * «big-demo»  (to ".big-demo")
 * «anim-make-each-frame»  (to ".anim-make-each-frame")
*
* (find-sh0 "ls -lAF /tmp/frame*")
* (find-sh0 "rm   -v /tmp/frame*")
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/topdf1.mac")
load       ("~/MAXIMA/topdf1.mac");
load_qdraw();

myxyrange()  := [xr(-2,5),yr(-2,3),more(proportional_axes=xy)];
drawing1(Dx) := para(cos(t)+Dx,sin(t), t,0,2*%pi);
drawing (Dx) := [myxyrange(), drawing1(Dx)];

[topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "frame", 0];
myqdrawp_to_new_pdf();

"To debug the drawing:
 myqdrawp_to_screen();
"$

** Create the frames 001..004 as .pdfs -
** if we're not in debugging/screen mode!
myqdrawp(drawing(0));
myqdrawp(drawing(0.5));
myqdrawp(drawing(1.0));
myqdrawp(drawing(1.5));
**
** Inspect the frames with:
** (find-fline "/tmp/" "frame_")


** «anim-make-frames.pdf»  (to ".anim-make-frames.pdf")
** See: https://github.com/qpdf/qpdf/issues/11#issuecomment-18768487
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
ls -lAF frame*
add_1zs () { for i in $*; do echo $i 1-z; done; }
                       add_1zs frame_*.pdf
qpdf --empty --pages $(add_1zs frame_*.pdf) -- frames.pdf
ls -lAF frame*
**
** Inspect frames.pdf with:
** (find-fline "/tmp/" "frames.pdf")
** (find-pdf-page "/tmp/frames.pdf")


** «anim-make-frames.gif»  (to ".anim-make-frames.gif")
** https://apple.stackexchange.com/questions/86177/imagemagick-convert-multipage-pdf-to-animated-gif
**
convert -alpha deactivate -verbose -delay 50 -loop 0 -density 150 \
  /tmp/frames.pdf /tmp/frames.gif
ls -lAF frame*
**
** See: file:///tmp/frames.gif
**       (brg "/tmp/frames.gif")

*/


/*   ___        _      _          _                      
 *  / _ \ _   _(_) ___| | __   __| | ___ _ __ ___   ___  
 * | | | | | | | |/ __| |/ /  / _` |/ _ \ '_ ` _ \ / _ \ 
 * | |_| | |_| | | (__|   <  | (_| |  __/ | | | | | (_) |
 *  \__\_\\__,_|_|\___|_|\_\  \__,_|\___|_| |_| |_|\___/ 
 *                                                       
 * «quick-demo»  (to ".quick-demo")
 * This is similar to the big demo, but goes straight to the point.
*
* (find-sh0 "ls -lAF /tmp/frame*")
* (find-sh0 "rm   -v /tmp/frame*")
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/topdf1.mac")
load       ("~/MAXIMA/topdf1.mac");
** (find-angg ".maxima/maxima-init.mac" "load_qdraw")
load_qdraw();

myxyrange()  := [xr(-2,5),yr(-2,3),more(proportional_axes=xy)];
drawing1(Dx) := para(cos(t)+Dx,sin(t), t,0,2*%pi);
drawing (Dx) := [myxyrange(), drawing1(Dx)];

[topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "frame", 0];
myqdrawp_to_new_pdf();    "Skip this line to draw to the screen"$

myqdrawp(drawing(0));
myqdrawp(drawing(0.5));
myqdrawp(drawing(1.0));
myqdrawp(drawing(1.5));

** Make the flipbook and the animated gif.
** Uses: (find-angg "MAXIMA/topdfanim1.sh")
**
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
./mkanim1.sh makeboth /tmp/frames.gif /tmp/frames.pdf /tmp/frame_*
**
** Inspect frames.pdf and frames.git with:
** (find-fline "/tmp/" "frames.pdf")
** (find-pdf-page "/tmp/frames.pdf")
**          file:///tmp/frames.gif
**           (brg "/tmp/frames.gif")

*/


/* TODO:
 * adjust ps, linewidth, impwidth
 * fazer myqdrawp
 * (find-angg "MAXIMA/myqdraw2.mac" "myqdraw")
*/





/*
 * Local Variables:
 * coding:  utf-8-unix
 * End:
*/