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

%*****************************************************************************80
%
%% polyiamond_grid_plot displays a parallelogram grid.
%
%  Discussion:
%
%    The user should call "clf()" before this function.
%    More plotting commands may be issued if preceded by the "hold on"
%    command.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 September 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer IMIN, JMIN, IMAX, JMAX, the range of the parallelogram.
%
%    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, is true if the triangle grid indices should be plotted.
%
  x1 = imin - 1 + ( jmin - 1 ) / 2;
  y1 =            ( jmin - 1 ) * sin ( pi / 3.0 );

  x2 = imax     + ( jmin - 1 ) / 2;
  y2 =            ( jmin - 1 ) * sin ( pi / 3.0 );

  x3 = imax     +   jmax       / 2;
  y3 =              jmax       * sin ( pi / 3.0 );

  x4 = imin - 1 +   jmax       / 2;
  y4 =              jmax       * sin ( pi / 3.0 );

  hold ( 'on' );

  fill ( [ x1, x2, x3, x4 ], [ y1, y2, y3, y4 ], color_back );

  label = '';

  for i = imin : imax
    for j = jmin : jmax
      for k = 0 : 1
        if ( number )
          grid_index = 1 + 2 * ( i - 1 + imax * ( j - 1 ) ) + k;
          label = sprintf ( '%d', grid_index );
        end
        triangle_ijk_fill ( i, j, k, r, color_tri, label );
      end
    end
  end

  hold ( 'off' );

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

  return
end
