function board_xy_init ( m, n, r, color_back, color_fore )

%*****************************************************************************80
%
%% board_xy_init() initializes the board.
%
%  Discussion:
%
%    An MxN array of squares is drawn, each filled with the same color,
%    and each of "radius" r.  As long as r <- 0.5, the board will fit
%    within a square of dimensions [0,M]x[1,N].
%
%    Note that the unit cell (i,j), with radius 1/2, is assumed to be centered 
%    at (i-0.5,j-0.5), with vertices (i-1,j-1), (i,j-1), (i,j), (i-1,j).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 October 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the height and width of the board, measured in unit cells.
%
%    real R, the radius of each cell.  A cell of radius 0.5 will
%    fill its unit square.  A cell of radius 0.45 will leave a margin
%    in which the board background color is visible.  R should not
%    exceed 0.5!
%
%    colors COLOR_BACK, COLOR_FORE.  These can be
%    any of the 8 abbreviated color terms 'r', 'g', 'b', 'c',
%    'm', 'y', 'w', 'k', or an RGB triple such as [1.0,0.4,0.0].
%    The board background is drawn with COLOR_BACK, and the board
%    cells are then drawn with COLOR_FORE.
%
  d = max ( 0.5 - r,  0.0 );

  fill ( [ - d, n + d, n + d, - d ], [ -d, -d, m + d, m + d ], color_back );

  hold ( 'on' );

  for x = 1 : n

    for y = 1 : m

      square_xy_fill ( x - 0.5, y - 0.5, r, color_fore );

    end
    
  end

  hold ( 'off' );

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

  return
end
