function life_display ( grid )

%*****************************************************************************80
%
%% life_display() displays a Life grid.
%
%  Discussion:
%
%    We assume the MxN grid is surrounded by a boundary layer of 0 cells.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 December 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer GRID(1+M+1,1+N+1), the data.
%
  [ mp2, np2 ] = size ( grid );

  m = mp2 - 2;
  n = np2 - 2;

  x_data_min = 1;
  x_data_max = n;
  y_data_min = 1;
  y_data_max = m;

  x_plot_min = x_data_min - 0.5;
  x_plot_max = x_data_max + 0.5;

  y_plot_min = y_data_min - 0.5;
  y_plot_max = y_data_max + 0.5;

  x_plot_range = x_plot_max - x_plot_min;
  y_plot_range = y_plot_max - y_plot_min;

  margin = 0.025 * max ( x_plot_range, y_plot_range );

  x_axes_min = x_plot_min - margin;
  x_axes_max = x_plot_max + margin;
  y_axes_min = y_plot_min - margin;
  y_axes_max = y_plot_max + margin;

  clf ( );

  gray = [ 0.9, 0.9, 0.9 ];

  hold ( 'on' );

  for i = 2 : m + 1

    for j = 2 : n + 1

      y = m + 2 - i;
      x = j - 1;

      a = x - 0.44;
      b = x + 0.44;
      c = y - 0.44;
      d = y + 0.44;

      patch ( [ a, b, b, a ], [ c, c, d, d ], gray, 'EdgeColor', 'none' );

      if ( grid ( i, j ) )
        a_min = 0.0      - 2.0 * pi / 18;
        a_max = 2.0 * pi - 2.0 * pi / 18;
        a = linspace ( a_min, a_max, 9 );
        x2 = x - 0.49 * cos ( a );
        y2 = y - 0.49 * sin ( a );
        fill ( x2, y2, 'r' );
      end

    end
    
  end

  hold ( 'off' );

  axis ( [ x_axes_min, x_axes_max, y_axes_min, y_axes_max ] );
  axis ( 'equal' );
  axis ( 'off' );
% axis ( [ -0.5, n+0.5, -0.5, m+0.5 ] );

  return
end
