%% ladybug3.mp
%% Created by Laurence D. Finston (LDF) Sat Jun 3 11:36:00 2023 +0200

%% * (1) Copyright and License.

%%%% Copyright (C) 2023 Laurence Finston

%%%% You can redistribute this file 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 

%%%% The author can be contacted at: 

%%%% Laurence.Finston@gmx.de

prologues := 3;

outputtemplate := "%j_%3c.eps";

% outputformat := "png";
% outputformatoptions := "format=rgb antialias=none";
% outputtemplate := "%j%3c.png";

cmykcolor magenta;
magenta = (0, 1, 0, 0);

cmykcolor cyan;
cyan = (1, 0, 0, 0);

cmykcolor yellow;
yellow = (0, 0, 1, 0);

input exteps;

%% ** (2) crosshair

def crosshair (expr A, B, C) =
  draw A shifted (-B, 0) -- A shifted (B, 0) withcolor C;
  draw A shifted (0, -B) -- A shifted (0, B) withcolor C;
enddef;


% (/ (- 420 20) 16.0) 
% (* 25.0 9) 225.0
% (/ 400 225.0) 1.7777777777777777
% (/ 16.0 9) 1.7777777777777777

frame_wd = 400mm;
frame_ht = 225mm;

path frame;

frame =    (-.5frame_wd, -.5frame_ht) -- (.5frame_wd, -.5frame_ht) -- (.5frame_wd, .5frame_ht)
        -- (-.5frame_wd, .5frame_ht) -- cycle;

pen medium_pen;
medium_pen := pencircle scaled .333mm;

pen big_pen;
big_pen := pencircle scaled .5mm;

pickup medium_pen;


picture v[];

beginfig(1);

  draw frame withpen big_pen;

  z0 = (point 0 of frame) shifted (1cm, 1cm);

  path q[];

  q0 = z0 shifted (0, -.5cm) -- z0 shifted (0, .5cm);
  q1 = z0 shifted (-.5cm, 0) -- z0 shifted (.5cm, 0);

  draw q0;
  draw q1;

  z1 = .5[point 0 of frame, point 1 of frame];
  z2 = .5[point 2 of frame, point 3 of frame];
  z3 = .5[point 0 of frame, point 3 of frame];
  z4 = .5[point 1 of frame, point 2 of frame];
  
  draw q0 reflectedabout (z1, z2);
  draw q1 reflectedabout (z1, z2);

  draw q0 reflectedabout (z3, z4);
  draw q1 reflectedabout (z3, z4);

  draw (q0 reflectedabout (z1, z2)) reflectedabout (z3, z4);
  draw (q1 reflectedabout (z1, z2)) reflectedabout (z3, z4);

  %dotlabel.top(btex $z_1$ etex, z1);
  %dotlabel.top(btex $z_2$ etex, z2);
  
  z5 = .5[point 0 of frame, point 2 of frame];

  

  z6 = (.5[point 0 of frame, point 3 of frame]) shifted (1cm, 0);
  draw z6 shifted (-.5cm, 0) -- z6 shifted (.5cm, 0);
  draw z6 shifted (0, -.5cm) -- z6 shifted (0, .5cm);

  %dotlabel.lft(btex $z_6$ etex, z6);
  
  z7 = (.5[point 1 of frame, point 2 of frame]) shifted (-1cm, 0);
  draw z7 shifted (-.5cm, 0) -- z7 shifted (.5cm, 0);
  draw z7 shifted (0, -.5cm) -- z7 shifted (0, .5cm);

  z8 = (.5[point 0 of frame, point 1 of frame]) shifted (0, 1cm);
  draw z8 shifted (-.5cm, 0) -- z8 shifted (.5cm, 0);
  draw z8 shifted (0, -.5cm) -- z8 shifted (0, .5cm);

  z9 = (.5[point 2 of frame, point 3 of frame]) shifted (0, -1cm);
  draw z9 shifted (-.5cm, 0) -- z9 shifted (.5cm, 0);
  draw z9 shifted (0, -.5cm) -- z9 shifted (0, .5cm);

  v0 = currentpicture;

  pickup big_pen;
  draw z5 shifted (-.5cm, 0) -- z5 shifted (.5cm, 0); % withcolor cyan;
  draw z5 shifted (0, -.5cm) -- z5 shifted (0, .5cm); % withcolor cyan;

  
endfig;

%% ** (2) Frame without crosshairs at center.

beginfig(10);
  currentpicture := v0;
endfig;

beginfig(11);
  unfill frame withpen big_pen;
endfig;

%% ** (2) Fig. 2.  Square frame.

path square_frame;

pair p[];

numeric square_frame_wd;
numeric square_frame_ht;

square_frame_wd = 22.5cm;
square_frame_ht = 22.5cm;

square_frame = (-.5square_frame_wd, -.5square_frame_ht) -- (.5square_frame_wd, -.5square_frame_ht) --
               (.5square_frame_wd, .5square_frame_ht) -- (-.5square_frame_wd, .5square_frame_ht)
               -- cycle;

for i = 0 upto 3:
  p[i] = point i of square_frame;
endfor;

for i = 0 upto 3:
  p[i+4] = .5[point i of square_frame, point ((i+1) mod 3) of square_frame];
endfor;

p8 = .5[point 0 of square_frame, point 2 of square_frame];


%% ** (2) Fig. 2.  Square green frame without blue crosshair.

beginfig(2);
  pickup big_pen;
  draw square_frame withpen pencircle scaled 1mm withcolor green;
endfig;


%% ** (2) Fig. 3.  Square green frame with blue crosshair.

beginfig(3);
  pickup big_pen;
  draw square_frame withpen pencircle scaled 1mm withcolor green;
  crosshair(p8, .5cm, blue);

endfig;

%% ** (2) Fig. 4.  Square white (invisible) frame.

beginfig(4);
  pickup big_pen;
  undraw square_frame withpen pencircle scaled 1mm;
endfig;

%% ** (2) End

end;

%% Local Variables:
%% mode:MetaPost
%% abbrev-mode:t
%% End:
