%% colorflow1.ldf
%% Created by Laurence D. Finston (LDF) Do 17. Aug 13:20:08 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\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[];

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 := true; % false; % 


color C[];

beginfig(300);
  unfill frame;
  draw frame with_pen big_pen;
  
  s :=   "\vbox to 0pt{\vss\hbox to 0pt{\hss\vbox{\hbox to 300mm{\hfil{\huge Color Flow Test Nr.~1}\hfil}\vskip2cm"
       & "\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);
endfig with_projection parallel_x_y;

beginfig(400);
  unfill frame;
  s :=   "\vbox to 0pt{\vss\hbox to 0pt{\hss\hbox to 300mm{\hfil{\huge The End}\hfil}\hss}\vss}";
  
  draw frame with_pen big_pen;
  label(s, p10);
endfig with_projection parallel_x_y;




%% ** (2) Red

i      := .1;
k      := 7/10;
save_k := 7/10;

for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (i, 0, 0);
  c[j] := unit_circle scaled (k, 0, k) rotated (90, 0);
  i += .1;
  k += save_k;
endfor;


k := 21;
for i = 0 upto 10:
  beginfig(i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      message "j == " & decimal j;
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;



%% ** (2) Green 

i      := .1;
k      := save_k;

for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (0, i, 0);
  i += .1;
endfor;

k := 43;
for i = 0 upto 10:
  beginfig(22+i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;



%% ** (2) Blue

i      := .1;
k      := save_k;

for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (0, 0, i);
  i += .1;
endfor;

k := 65;
for i = 0 upto 10:
  beginfig(44+i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;


%% ** (2) Cyan

i      := .1;
k      := save_k;


for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (0, i, i);
  i += .1;
endfor;

k := 87;
for i = 0 upto 10:
  beginfig(66+i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;




%% ** (2) Magenta

i      := .1;
k      := save_k;

for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (i, 0, i);
  i += .1;
endfor;

k := 109;
for i = 0 upto 10:
  beginfig(88+i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;



%% ** (2) Yellow

i      := .1;
k      := save_k;

for j = 0 upto 10:
  message "j == " & decimal j;
  C[j] := (i, i, 0);
  i += .1;
endfor;

k := 131;
for i = 0 upto 10:
  beginfig(110+i);
    unfill frame;
    draw frame with_pen big_pen;
    fill c[i] with_color C[i];
    for j = (i-1) downto 1:
      if j >= 0:
	fill c[j] with_color C[j];
      fi;
    endfor;
    v0 := current_picture;
  endfig with_projection parallel_x_y;
  beginfig(k);
    current_picture := v0;
  endfig with_projection parallel_x_y;
  k-=1;
endfor;


bye;

%% ** (2)






%% ** (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:
