function grid_plot ( imin, imax, jmin, jmax, r, color_back, color_tri, number )

%*****************************************************************************80
%
%% grid_plot() displays a grid.
%
%  Discussion:
%
%    The user should call "clf()" before this function.
%
%    The user should call "hold('off')" to close this plot.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 December 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer IMIN, IMAX, JMIN, JMAX: the range of the grid.
%
%    real R: controls the size of the component triangles.
%    0 <= R<= 1.  Use R=0.95 for triangles that don't completely fill
%    the region.
%
%    color COLOR_BACK, COLOR_TRI: colors for the background and the triangles.
%
%    logical NUMBER: true if the triangle grid indices should be plotted.
%
  hold ( 'on' );

  fill ( [ imin - 1, imax, imax, imin - 1 ], [ jmin - 1, jmin - 1, jmax, jmax ], color_back );

  label = '';

  for i = imin: imax
    for j = jmin : jmax
      for k = 0 : 3
        ijk = [ i, j, k ];
        ijk_fill ( ijk, r, color_tri, label );
      end
    end
  end

  if ( number )
    for i = imin : imax
      for j = jmin: jmax
        for k = 0 : 3
          grid_index = 1 + 4 * ( i - 1 + imax * ( j - 1 ) ) + k;
          label = sprintf ( '%d', grid_index );
          ijk = [ i, j, k ];
          ijk_fill ( ijk, r, color_tri, label );
        end
      end
    end
  end
%
%  Mark the origin.
%
  plot ( 0.0, 0.0, 'k.', 'markersize', 35 );

  axis ( 'equal' );
  axis ( 'off' );

  return
end

