function tetrahedron_slice_movie ( )

%*****************************************************************************80
%
%% tetrahedron_slice_movie() creates an AVI animation from frame files.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 December 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'tetrahedron_slice_movie()\n' );
  fprintf ( 1, '  Create an AVI animation from a sequence of frame files.\n' );
%
%  Control how fast final movie will play; total time
%  of movie in seconds will be about (numframes)/(num_frames_per_second)
%
  FrameRate = 10;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The number of frames per second will be %f\n', FrameRate );
%
%  The VIDEOWRITER function creates a new Audio Video Interleaved (AVI) file.
%
  filename = 'tetrahedron_slice_movie.avi';
  V = VideoWriter ( filename );
  V.FrameRate = FrameRate;
  open ( V );
  fprintf ( 1, '  Creating animation file "%s"\n', filename );
%
%  Retrieve each frame.
%
  frame_id = 1;

  while ( true )

    filename = sprintf ( 'frame%04d.jpg', frame_id );
    if ( ~ isfile ( filename ) )
      break;
    end

    H = imshow ( filename );
    set ( H, 'EraseMode', 'xor' );
    set ( gca, 'nextplot', 'replacechildren' );
    shading ( 'interp' );
    axis ( 'tight' );
    axis ( 'square' );
    axis ( 'off' );
 
    frame = getframe ( gca );
    writeVideo ( V, frame );

    frame_id = frame_id + 1;

  end
%
%  Tell MATLAB we have completed the movie.
%
  close ( V );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'tetrahedron_slice_movie:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

