Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
/*
 * This file:
 *   http://anggtwu.net/MAXIMA/bezier2.mac.html
 *   http://anggtwu.net/MAXIMA/bezier2.mac
 *          (find-angg "MAXIMA/bezier2.mac")
 * Author: Eduardo Ochs <eduardoochs@gmail.com>
 * Version: 2024oct16
 * Public domain.
 *
 * I used this file to generate this animation:
 *   http://anggtwu.net/eev-maxima.html#qdraw
 *   http://anggtwu.net/LATEX/2024-2-C3/bezier_anim_small.gif
 *   http://anggtwu.net/LATEX/2024-2-C3/bezier_anim_big.gif
 *   http://anggtwu.net/LATEX/2024-2-C3/bezier_flipbook.pdf
 *
 * It uses these three libraries, that are reasonably well-documented,
 *   (find-angg "MAXIMA/myqdraw3.mac")
 *   (find-angg "MAXIMA/topdf1.mac")
 *   (find-angg "MAXIMA/mkanim1.sh")
 * but this file is a mess... =(
 *
 * (defun e () (interactive) (find-angg "MAXIMA/bezier2.mac"))
 * (defun o () (interactive) (find-angg "MAXIMA/bezier1.mac"))
 * (defun a () (interactive) (find-angg "MAXIMA/mkanim1.sh"))
 * (defun p () (interactive) (find-angg "MAXIMA/topdf1.mac"))
 * (defun m () (interactive) (find-angg "MAXIMA/myqdraw3.mac"))
*/


bezier4_(P0,P1,P2,P3) := block(
  local(towt, Q0,Q1,Q2, R0,R1, S0),
  towt(A, B) := A + t*(B-A),
  [Q0, Q1, Q2] : [towt(P0,P1), towt(P1,P2), towt(P2,P3)],
  [R0, R1]     : [towt(Q0,Q1), towt(Q1,Q2)],
  [S0]         : [towt(R0,R1)],
  ['P0=P0, 'P1=P1, 'P2=P2, 'P3=P3,
   'Q0=Q0, 'Q1=Q1, 'Q2=Q2,
   'R0=R0, 'R1=R1,
   'S0=S0]
  )$

bezier4_export(P0,P1,P2,P3) := block(
  local(b4),
  b4 : bezier4_(P0, P1, P2, P3),
  define(Q0(t), subst(b4, Q0)),
  define(Q1(t), subst(b4, Q1)),
  define(Q2(t), subst(b4, Q2)),
  define(R0(t), subst(b4, R0)),
  define(R1(t), subst(b4, R1)),
  define(S0(t), subst(b4, S0))
  )$

/* (find-es "qdraw" "para")
 * (find-es "qdraw" "pts")
*/
mypara(Poft,  [opts]) := myapply_fl('para, Poft[1],Poft[2], t,0,1, opts);
mypts (PList, [opts]) := myapply_fl('pts,  PList, opts);

bezier4_paras(P0,P1,P2,P3) := block(
  local(Q0,Q1,Q2, R0,R1, S0),
  bezier4_export(P0,P1,P2,P3),
  [mypara(Q0(t), lc(red)),
   mypara(Q1(t), lc(red)),
   mypara(Q2(t), lc(red)),
   mypara(R0(t), lc(orange)),
   mypara(R1(t), lc(orange)),
   mypara(S0(t), lc(forest_green))]
  )$

bezier4_pts(P0,P1,P2,P3,tt,[opts]) := block(
  local(Q0,Q1,Q2, R0,R1, S0),
  bezier4_export(P0,P1,P2,P3),
  [mypts([Q0(tt),Q1(tt),Q2(tt)], pc(red),          opts),
   mypts([R0(tt),R1(tt)],        pc(orange),       opts),
   mypts([S0(tt)],               pc(forest_green), opts)]
  )$


bezier4_all     (P0,P1,P2,P3,tt,[opts]) :=
  [bezier4_paras(P0,P1,P2,P3),
   bezier4_pts  (P0,P1,P2,P3,tt,[opts])]$



/*
* (find-sh0 "ls -lAF /tmp/frame*")
* (find-sh0 "rm   -v /tmp/frame*")
*
* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-angg "MAXIMA/myqdraw3.mac")
load       ("~/MAXIMA/myqdraw3.mac");
** (find-angg "MAXIMA/topdf1.mac")
load       ("~/MAXIMA/topdf1.mac");
load("bezier2.mac");

myps(size)  := ps(size/4);
myopts()    := [myps(2),pj(1)];

"Choose one";
myxyrange() := [xr(-0.5,3.0),yr(-0.5,2.0),more(proportional_axes=xy)];
myxyrange() := [xr(-0.5,3.0),yr(-0.5,2.0),more(proportional_axes=xy),cut(all)];
myxyrange() := [xr(-0.5,2.5),yr(-0.5,1.5),more(proportional_axes=xy),cut(all)];
myxyrange() := [xr(-0.1,2.1),yr(-0.1,1.1),more(proportional_axes=xy),cut(all)];
myxyrange() := [xr(-0.0,2.0),yr(-0.0,1.0),more(proportional_axes=xy),cut(all)];
bezier4_alls(ttts) :=
    makelist(bezier4_all(P0,P1,P2,P3, ttt, myopts()), ttt, ttts);

[P0,P1,P2,P3] : [[0,0], [0,1], [2,1], [1,0]];

"Draw to PDFs:"$
[topdf_a,topdf_b,topdf_c,topdf_n] : ["/tmp/", "", "frame", 0];
myps(size) := ps(size/3); myqdrawp_to_new_pdf();
tt : 0.2;
for tt in seqn (0,1,20) do
    myqdrawp(myxyrange(), bezier4_alls([tt]));


"Draw to screen:"$
myps(size) := ps(size); myqdrawp_to_screen();
myqdrawp(myxyrange(), bezier4_alls([0]));
myqdrawp(myxyrange(), bezier4_alls([0.1]));
myqdrawp(myxyrange(), bezier4_alls([0.2]));
myqdrawp(myxyrange(), bezier4_alls([0.3]));
myqdrawp(myxyrange(), bezier4_alls([0.4]));
myqdrawp(myxyrange(), bezier4_alls([0.5]));
myqdrawp(myxyrange(), bezier4_alls([0.6]));
myqdrawp(myxyrange(), bezier4_alls([0.7]));
myqdrawp(myxyrange(), bezier4_alls([0.8]));
myqdrawp(myxyrange(), bezier4_alls([0.9]));
myqdrawp(myxyrange(), bezier4_alls([1.0]));

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
cd /tmp/
laf frame*
laf bezier*
~/MAXIMA/mkanim1.sh DENSITY=200 makeboth bezier_anim_big.gif   bezier_flipbook.pdf frame_*.pdf
~/MAXIMA/mkanim1.sh DENSITY=75  makeboth bezier_anim_small.gif bezier_flipbook.pdf frame_*.pdf

# (brg "/tmp/bezier_big.gif")
# (brg "/tmp/bezier_small.gif")
# (brg "/tmp/frames.gif")

*/


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