%% colorsweep1.ldf
%% Created by Laurence D. Finston (LDF) Di 22. Aug 06:05:06 CEST 2023

%% * (1) Copyright and License.

%%%% Copyright (C) 2023 Laurence Finston

%%%% This file is free software; you can redistribute it and/or modify 
%%%% it under the terms of the GNU General Public License as published by 
%%%% the Free Software Foundation; either version 3 of the License, or 
%%%% (at your option) any later version.  

%%%% This file is distributed in the hope that it will be useful, 
%%%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
%%%% GNU General Public License for more details.  

%%%% You should have received a copy of the GNU General Public License 
%%%% along with this file; if not, write to the Free Software 
%%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 

%%%% Please send bug reports to Laurence.Finston@gmx.de

%%%% The author can be contacted at: 

%%%% Laurence Finston 
%%%% Laurence.Finston@gmx.de

input "plainldf.lmc";

medium_pen := pencircle scaled (.333mm, .333mm, .333mm);

verbatim_tex "\magnification=\magstep2\font\huge=cmbx12 scaled 4000"
  & "\font\Huge=cmbx12 scaled 6000"
  & "\font\Large=cmbx12 scaled 3000"
  & "\font\large=cmbx12 scaled 1600";

%verbatim_metapost "prologues := 3;outputtemplate := \"%j_%3c.eps\";dotlabeldiam:=2mm;";

verbatim_metapost   "outputformat:=\"png\";outputtemplate := \"%j_%3c.png\";"
                  & "outputformatoptions := \"format=rgb antialias=none\";";

%% * (1)

point p[];
path q[];
rectangle r[];
transform t[];
picture v[];

triangle T[];

circle c[];

string s;

focus f;

set f with_position (0, 10, -40) with_direction (0, 10, 10) 
  with_distance 45;

numeric frame_wd;
numeric frame_ht;

% \special{papersize=400mm, 225mm} %% Frame size, proportion 16x9
% \hsize=400mm
% \vsize=225mm

%% (* (/ 300 16.0) 9) 168.75

frame_wd := 300mm;
frame_ht := 168.75mm;

rectangle frame;

frame := ((-.5frame_wd, -.5frame_ht), (.5frame_wd, -.5frame_ht),
          (.5frame_wd, .5frame_ht), (-.5frame_wd, .5frame_ht));

p10 := get_center frame;

%% * (1)

pickup medium_pen;

pickup medium_pen;

dot_pen := pencircle scaled (2mm, 2mm, 2mm);

bool do_labels;
do_labels := false; % true; % 


color C[];

%% * (1)

for i = 0 upto 3:
  p[i] := get_point (i) frame;
endfor;

for i = 0 upto 3:
  p[i+4] := mediate(get_point (i) frame, get_point((i+1) mod 4) frame);
endfor;

%% * (1)

beginfig(1000);
  fill frame;
  
  s :=   "\vbox to 0pt{\vss\vskip1cm\hbox to 0pt{"
       & "\hss\vbox{\hbox to 300mm{\hfil{\huge Color Sweep Nr.~1}\hfil}\vskip1.5cm"
       & "\hbox to 300mm{\hfil{\Large By}\hfil}\vskip1cm"
       & "\hbox to 300mm{\hfil{\Large Laurence Finston}\hfil}\vskip2.5cm"
       & "\hbox to 300mm{\hfil{\large Copyright (C) 2023 Laurence Finston}\hfil}"
       & "}\hss}\vss}";

  label(s, p10) with_color white;
endfig with_projection parallel_x_y;

beginfig(1001);
  fill frame;
  s :=   "\vbox to 0pt{\vss\hbox to 0pt{\hss\hbox to 300mm{\hfil{\Huge The End}\hfil}\hss}\vss}";
  label(s, p10) with_color white;;
endfig with_projection parallel_x_y;

%% * (1)

point a[];

beginfig(0);
  unfill frame;
  draw frame with_pen big_pen;

  if do_labels:
    dotlabel.bot("$p_0$", p0) shifted (0, -2);
    dotlabel.bot("$p_1$", p1) shifted (0, -2);
    dotlabel.top("$p_2$", p2) shifted (0, 2);
    dotlabel.top("$p_3$", p3) shifted (0, 2);
    dotlabel.bot("$p_4$", p4) shifted (0, -2);
    dotlabel.rt("$p_5$", p5) shifted (3, 0);;
    dotlabel.top("$p_6$", p6) shifted (0, 2);
    dotlabel.lft("$p_7$", p7) shifted (-2, 0);
  fi;
  
  for i = 0 upto 20:
    a[i] := mediate(p0, p1, i*1/20);
    s := "$\scriptstyle a_{" & decimal (i) & "}$";
    if do_labels:
      dotlabel.bot(s, a[i]);
    fi;

    a[i+31] := mediate(p3, p2, i*1/20);
    s := "$\scriptstyle a_{" & decimal (i+31) & "}$";
    if do_labels:
      label.top(s, a[i+31]) shifted (0, .25);
      drawdot a[i+31] with_pen pencircle scaled (2mm, 2mm, 2mm);
    fi;
  endfor;

  for i = 0 upto 9:
    a[i+21] := mediate(p0, p3, i*1/10);
    s := "$\scriptstyle a_{" & decimal (i+21) & "}$";

    if do_labels:
      dotlabel.lft(s, a[i+21]);
    fi;


    a[i+52] := mediate(p1, p2, i*1/10);
    s := "$\scriptstyle a_{" & decimal (i+52) & "}$";

    if do_labels:
      label.rt(s, a[i+52]) shifted (.25, 0);
      drawdot a[i+52] with_pen pencircle scaled (2mm, 2mm, 2mm);
    fi;
  endfor;

  if do_labels:
    label.bot("$o$", origin) shifted (-4pt, -2pt);
    drawdot origin with_pen dot_pen;
  fi;
 

  for i = 0 upto 19:
    q[i] := a0 -- a[32+i] -- a[31+i] -- cycle;
    %draw q[i];
  endfor;

  q20 := a0 -- a51 -- a61 -- cycle;
  %draw q20;
  
  for i = 0 upto 8:
    q[21+i] := a0 -- a[61-i] -- a[60-i] -- cycle;
    %draw q[21+i];
  endfor;
  
 
  v0 := current_picture;

endfig with_projection parallel_x_y;

%% * (1)

color_vector cv[];

color c;


n := 6/300;

for i = 30 downto 0:
  c := (.4+(i*n), 0, 0);
  cv += c;
endfor;

for i = 30 downto 0:
  c := (0, .4+(i*n), 0);
  cv += c;
endfor;

for i = 30 downto 0:
  c := (0, 0, .4+(i*n));
  cv += c;
endfor;

for i = 30 downto 0:
  c := (.4+(i*n), .4+(i*n), 0);
  cv += c;
endfor;

for i = 30 downto 0:
  c := (.4+(i*n), 0, .4+(i*n));
  cv += c;
endfor;

for i = 30 downto 0:
  c := (0, .4+(i*n), .4+(i*n));
  cv += c;
endfor;

for i = 30 downto 0:
  c := ((.4+(i*n)*.75), (.4+(i*n)*.25), 0);
  cv += c;
endfor;

for i = 30 downto 0:
  c := ((.4+(i*n)*.75), 0, (.4+(i*n)*.25));
  cv += c;
endfor;

for i = 30 downto 0:
  c := (0, (.4+(i*n)*.75), (.4+(i*n)*.25));
  cv += c;
endfor;

for i = 1 upto 30:
  k := 0;
beginfig(i);
  current_picture := v0;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v1 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 31;
  beginfig(30+i);
    current_picture := v1;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v2 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;


for i = 1 upto 30:
  k := 62;
  beginfig(60+i);
  current_picture := v2;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v3 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 93;
  beginfig(90+i);
  current_picture := v3;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v4 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 124;
  beginfig(120+i);
  current_picture := v4;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v5 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 155;
  beginfig(150+i);
  current_picture := v5;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v6 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 186;
  beginfig(180+i);
  current_picture := v6;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v7 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 217;
  beginfig(210+i);
  current_picture := v7;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v8 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;

for i = 1 upto 30:
  k := 248;
  beginfig(240+i);
  current_picture := v8;
  for j = (i - 1) downto 0:
    fill q[j] with_color cv[k];
    k+=1;
  endfor;
  if i == 30:
    v9 := current_picture;
  fi;
endfig with_projection parallel_x_y;
endfor;




bye;





bye;

%% * (1) Red

n := 1/27;


for i = 0 upto 29:
  beginfig(i+1);
    current_picture := v0;
    for j = i downto 0:
      C0 := (.3+n*j, 0, 0);
      %fill q[j] with_color C0;
    endfor;
    if i == 29:
      v1 := current_picture;
    fi;
  endfig with_projection parallel_x_y;
endfor;
endfig with_projection parallel_x_y;
endfor;



bye;



bye;

%% ** (2) 

%% * (1) Emacs-Lisp code for use in indirect buffers when using the          
%%       GNU Emacs editor.  The local variable list is not evaluated when an 
%%       indirect buffer is visited, so it's necessary to evaluate the       
%%       following s-expression in order to use the facilities normally      
%%       accessed via the local variables list.                              
%%       LDF 2004.02.12.

%% (progn (metafont-mode) (outline-minor-mode t) (setq fill-column 80) (ignore '(  
%% )) (setq outline-regexp "%% [*\f]+"))

%% * (1) Local variables for Emacs.

%% Local Variables:
%% mode:Metapost
%% eval:(outline-minor-mode t)
%% eval:(read-abbrev-file abbrev-file-name)
%% outline-regexp:"%% [*\f]+"
%% End:
