Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/myqdraw2.mac.html
 *   http://anggtwu.net/MAXIMA/myqdraw2.mac
 *          (find-angg "MAXIMA/myqdraw2.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 *
 * (defun e () (interactive) (find-angg "MAXIMA/myqdraw2.mac"))
 * (defun o () (interactive) (find-angg "MAXIMA/myqdraw2.mac"))
 *
 * `myqdraw' is like `qdraw', but it flattens its arguments, 
 * This file defines `myqdraw' and several tools for it.
 *
 * Note that the suffix "1" has several meanings:
 *    qdraw1 (line(1,2,3,4))  returns drlist instead of drawing it
 *  myqdraw1 (line(1,2,3,4))  returns drlist instead of drawing it
 *  myqdraw1v(line(1,2,3,4))  returns drlist in "vertical format"
 *  myqdraw1.mac             is an older version of these functions
 *  myapply (f,[L])          receives f and a vararg
 *  myapply1(f, L )          receives a single list instead of a vararg
 *
 * «.myqdraw»			(to "myqdraw")
 * «.myapply»			(to "myapply")
 * «.xyrange»			(to "xyrange")
 * «.mypara»			(to "mypara")
 * «.myPvec»			(to "myPvec")
 * «.myPv»			(to "myPv")
 * «.myterminalpdf»		(to "myterminalpdf")
 * «.mypdf»			(to "mypdf")
 * «.mypdf-tests»		(to "mypdf-tests")
 * «.myqdraw_pdf»		(to "myqdraw_pdf")
 * «.myqdraw_pdf-tests»		(to "myqdraw_pdf-tests")
*/


/* «myqdraw»  (to ".myqdraw")
 * (find-angg ".maxima/maxima-init.mac" "load_qdraw")
*/
load_qdraw();
myqdraw_prep([qargs]) := flatten([qargs]);
myqdraw     ([qargs]) := apply('qdraw,   myqdraw_prep(qargs));
myqdraw1    ([qargs]) := apply('qdraw1,  myqdraw_prep(qargs));
myqdraw1v   ([qargs]) := apply('qdraw1v, myqdraw_prep(qargs));
myqdrawv    ([qargs]) := apply('qdrawv,  myqdraw_prep(qargs));
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");
[p1, p2, p3] : [pts([[1,1]]), pts([[2,2]]), pts([[3,3]])];
  qdraw1v (p1,  p2, p3);
myqdraw1v([p1, [p2, p3]]);
myqdrawv ([p1, [p2, p3]]);
myqdraw  ([p1, [p2, p3]]);
  qdraw   (p1,  p2, p3);

*/


/*
 * «myapply»  (to ".myapply")
 * See: (find-es "maxima" "myapply")
*/
butlast       (L)  := firstn(L, length(L)-1);
expandlast    (L)  := append(butlast(L), last(L));
flattenlast   (L)  := append(butlast(L), flatten([last(L)]));
myapply    (f,[L]) := apply(f, expandlast(L));
myapply1   (f, L ) := apply(f, expandlast(L));
myapply1_fl(f, L ) := apply(f, flattenlast(L));
myapply_fl (f,[L]) := apply(f, flattenlast(L));
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");
apply      (foo, [[x0,y0],[x1,y1]]);
myapply    (foo,  [x0,y0],[x1,y1], [[2,3],[4,5]] );
myapply1   (foo, [[x0,y0],[x1,y1], [[2,3],[4,5]]]);
myapply1_fl(foo, [[x0,y0],[x1,y1], [[2,3],[4,5]]]);

*/



/* «xyrange»  (to ".xyrange")
*/
[xmin,ymin, xmax,ymax] : [-1,-1, 5,4];
xyrange() := [xr(xmin,xmax), yr(ymin,ymax), more(proportional_axes=xy)];
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("myqdraw2.mac");
[xmin,ymin, xmax,ymax] : [-2,-2, 10,6];
myqdraw(xyrange(), para(cos(t),sin(t), t,0,2*%pi));

*/




/* «mypara»  (to ".mypara")
*/
mypara(xy,[rest]) := myapply('para, xy[1],xy[2], rest);
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("myqdraw2.mac");
P(t) := [cos(t),sin(t)];
myqdraw(xyrange(), mypara(P(t)+[2,2], t,0,2*%pi));

*/



/* «myPv»  (to ".myPv")
*/
myPv (P,v,      Popts,[vopts]) := 
  [myapply_fl('pts,    [P], Popts),
   myapply_fl('vector, P,v, vopts)];
myPPe(P0,P1,eps,Popts,[vopts]) := 
  [myapply_fl('pts,    [P0,P1],        Popts),
   myapply_fl('vector, P0,(P1-P0)/eps, vopts)];

myPopts          (colr) := [pc(colr),ps(2)];
myvopts          (colr) := [lc(colr),hl(0.15),ht(f)];
myPv_c (P,v,      colr) := myPv (P,v,       myPopts(colr), myvopts(colr));
myPPe_c(P0,P1,eps,colr) := myPPe(P0,P1,eps, myPopts(colr), myvopts(colr));

/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");
P(t) := [cos(t),sin(t)] + [2,1];
define(vel(t), diff(P(t),t));
myqdraw(xyrange(),
        mypara (P(t), t,0,2*%pi, lc(orange)),
        myPv_c (P(1), vel(1),      red),
        myPPe_c(P(2), P(3.2), 1.2, forest_green),
        myPPe_c(P(2), P(2.5), 0.5, forest_green),
        myPPe_c(P(2), P(2.2), 0.2, forest_green)
        );

*/



/* «myterminalpdf»  (to ".myterminalpdf")
*/
myterminalpdf         (stem) := more(terminal=pdf, file_name=stem);
myincludegraphics(opts,stem) := format("\\includegraphics[~a]{~a.pdf}", opts, stem);
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");

* (find-sh0 "ls -lAF /tmp/test*")
* (find-sh0 "rm -fv  /tmp/test*")

P(t)   := [cos(t),sin(t)] + [2,1];
drawing : [xyrange(), mypara(P(t), t,0,2*%pi)];
myqdraw(drawing);
myqdraw(drawing, myterminalpdf("/tmp/test"));
myincludegraphics("height=3cm",     "test");

* (find-pdf-page "/tmp/test.pdf")

*/



/* «mypdf»  (to ".mypdf")
 * (find-angg "MAXIMA/myqdraw1.mac" "includegraphics")
*/
mypdf_basedir : "/tmp/";
mypdf_subdir  : "";
mypdf_stem    : "test_nonumber";
mypdf_substem : "test_";
mypdf_n       : 0;
mypdf_opts    : "height=5cm";
mypdf_subdirstem () := format("~a~a", mypdf_subdir, mypdf_stem)$
mypdf_fulldirstem() := format("~a~a~a", mypdf_basedir, mypdf_subdir, mypdf_stem)$
mypdf_terminalpdf() := more(terminal=pdf, file_name=mypdf_fulldirstem())$
mypdf_includegraphics() := format("\\includegraphics[~a]{~a.pdf}",
                                   mypdf_opts, mypdf_subdirstem());

/* Three functions with side effects: */
mypdf_stemn  () := (mypdf_stem : format("~a~3,'0d", mypdf_substem, mypdf_n));
mypdf_npp    () := (mypdf_n : mypdf_n+1)$
mypdf_stemnpp() := (mypdf_n : mypdf_n+1, mypdf_stemn())$

/*
 * «mypdf-tests»  (to ".mypdf-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");
mypdf_stemnpp();
mypdf_stemnpp();
mypdf_fulldirstem();
mypdf_includegraphics();
mypdf_terminalpdf();

* (find-sh0 "ls -lAF /tmp/test*")
* (find-sh0 "rm -fv  /tmp/test*")

[p1,p2,p3] : [pts([[1,1]]), pts([[2,2]]), pts([[3,3]])];
mypdf_n    : 0;
mypdf_npp();
myqdrawv (p1,p2,p3);
myqdrawv (p1,p2,p3, mypdf_terminalpdf());
myqdraw  (p1,p2,p3, mypdf_terminalpdf());
mypdf_includegraphics();

** (find-pdf-page "/tmp/test_002.pdf")

*/

/* «myqdraw_pdf»  (to ".myqdraw_pdf")
 * When `myqdraw_pdf' is `myqdraw_pdf_draw' nothing special happens.
 * When `myqdraw_pdf' is `myqdraw_pdf_save' each new call to
 *   `myqdraw_pdf' saves a new pdf file.
*/
myqdraw_pdf_draw([args]) := myqdraw(args);
myqdraw_pdf_save([args]) :=
  (mypdf_stemnpp(),
   myqdraw(mypdf_terminalpdf(), args),
   mypdf_includegraphics());
myqdraw_pdf([args]) := myqdraw_pdf_save(args);
myqdraw_pdf([args]) := myqdraw_pdf_draw(args);

/*
 * «myqdraw_pdf-tests»  (to ".myqdraw_pdf-tests")
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw2.mac")
load       ("~/MAXIMA/myqdraw2.mac");
[p1,p2,p3] : [pts([[1,1]]), pts([[2,2]]), pts([[3,3]])];

* (find-sh0 "ls -lAF /tmp/test*")
* (find-sh0 "rm -fv  /tmp/test*")

myqdraw_pdf(p1,p2,p3);
myqdraw_pdf([args]) := myqdraw_pdf_draw(args);
myqdraw_pdf([args]) := myqdraw_pdf_save(args);
myqdraw_pdf(p1,p2);
myqdraw_pdf(p1,p2,p3);

** (find-pdf-page "/tmp/test_001.pdf")
** (find-pdf-page "/tmp/test_002.pdf")

*/




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