Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/myqdraw3.mac.html
 *   http://anggtwu.net/MAXIMA/myqdraw3.mac
 *          (find-angg "MAXIMA/myqdraw3.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 *
 * This is "myqdraw3.mac" - my third attempt to extend qdraw
 * in useful ways. Qdraw is this:
 *
 *   https://home.csulb.edu/~woollett/mbe.html
 *   https://home.csulb.edu/~woollett/mbe13qdraw.pdf
 *   https://home.csulb.edu/~woollett/qdraw.mac
 *   (find-windows-beginner-intro "12. Install qdraw")
 *
 * This file defines `myqdraw' and several variants for it.
 * `myqdraw' is like `qdraw', but it flattens its arguments.
 * Here are the explanations for the suffixes and prefixes:
 *
 *   The prefix "my" means "flatten the arguments".
 *   The suffix "v" means "vertical output" (for debugging).
 *   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
 *
 *   The suffix "p" means "to pdf".
 *   The variants with "p" are defined here:
 *     (find-angg "MAXIMA/topdf1.mac" "myqdrawp-modes")
 *
 * This file loads both "qdraw.mac" and "topdf1.mac". See:
 *   (find-angg ".maxima/maxima-init.mac" "load_qdraw")
 *   (find-angg "MAXIMA/topdf1.mac")
 *
 * (defun q3 () (interactive) (find-angg "MAXIMA/myqdraw3.mac"))
 * (defun q2 () (interactive) (find-angg "MAXIMA/myqdraw2.mac"))
 *
 * «.myqdraw»			(to "myqdraw")
 * «.myapply»			(to "myapply")
 * «.xyrange»			(to "xyrange")
 * «.mypara»			(to "mypara")
 * «.pts_open»			(to "pts_open")
 * «.myPvec»			(to "myPvec")
 * «.myPv»			(to "myPv")
 * «.myterminalpdf»		(to "myterminalpdf")
*/


/* «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/myqdraw3.mac")
load       ("~/MAXIMA/myqdraw3.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/myqdraw3.mac")
load       ("~/MAXIMA/myqdraw3.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("myqdraw3.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("myqdraw3.mac");
P(t) := [cos(t),sin(t)];
myqdraw(xyrange(), mypara(P(t)+[2,2], t,0,2*%pi));

*/

/* «pts_open»  (to ".pts_open")
 * (find-es "qdraw" "point-types")
*/
pt_open   : pt(6);
pt_closed : pt(7);
pts_open(coords, [opts]) :=
  [myapply_fl('pts, coords, pc(white),pt_closed,opts),
   myapply_fl('pts, coords,           pt_open,  opts)];
/*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
load("myqdraw3.mac");
myqdraw(xr(-1,4),yr(-1,3),
        para(x,1, x,1,3),
        pts_open([[1,1],[2,1]]),
        pts     ([[3,1]]));

*/




/* «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/myqdraw3.mac")
load       ("~/MAXIMA/myqdraw3.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")
 * Similar to: (find-angg "MAXIMA/topdf1.mac")
 * but more primitive.
*/
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/myqdraw3.mac")
load       ("~/MAXIMA/myqdraw3.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")

*/




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