Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
/* * This file: * http://anggtwu.net/myqdraw/topdf1.mac.html * http://anggtwu.net/myqdraw/topdf1.mac * (find-myqdraw "topdf1.mac") * See: * http://anggtwu.net/eev-qdraw.html * Author: Eduardo Ochs <eduardoochs@gmail.com> * Version: 2024nov12 * Public domain. * * This file defines 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-myqdraw "mkanim1.sh") * (find-myqdraw "myqdraw-tex.lisp" "includegraphics") * * «.topdf-modes» (to "topdf-modes") * «.topdf-modes-test» (to "topdf-modes-test") * «.myqdrawp-modes» (to "myqdrawp-modes") * «.myqdrawp-modes-test» (to "myqdrawp-modes-test") * «.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_includegraphics() := includegraphics(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-myqdraw "topdf1.mac") load_myqdraw(); 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_") */ /* ___ _ _ _ * / _ \ _ _(_) ___| | __ __| | ___ _ __ ___ ___ * | | | | | | | |/ __| |/ / / _` |/ _ \ '_ ` _ \ / _ \ * | |_| | |_| | | (__| < | (_| | __/ | | | | | (_) | * \__\_\\__,_|_|\___|_|\_\ \__,_|\___|_| |_| |_|\___/ * ** «quick-demo» (to ".quick-demo") * (find-sh0 "ls -lAF /tmp/frame*") * (find-sh0 "rm -v /tmp/frame*") * * (eepitch-maxima) * (eepitch-kill) * (eepitch-maxima) load_myqdraw(); [topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "frame", 0]; myqdrawp_to_screen (); myqdrawp_to_new_pdf(); "Skip this line to draw to the screen"$ [xmin,xmax, ymin,ymax] : [-2,5, -2,3]; drawing1(Dx) := para(cos(t)+Dx,sin(t), t,0,2*%pi); drawing (Dx) := [xyrange(), drawing1(Dx)]; ** 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_") ** Now make the flipbook and the animated gif, with: ** (find-myqdraw "mkanim1.sh") ** * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) ./mkanim1.sh ECHO=and_run 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") */