function ijk_fill ( ijk, r, color, label )

%*****************************************************************************80
%
%% ijk_fill() plots a filled ijk triangle.
%
%  Discussion:
%
%    The (i,j) coordinates refer to a parallelogram whose basic cell
%    is the unit parallelogram outlined by points (A,B,C,D)
%    with (i,j) coordinates
%      A = (0,0) --> B = (1,0) --> C = (1,1) --> D = (0,1).
%
%         D-----C
%        /     /
%       /     /
%      A-----B
%
%    Each cell is divided into k=0 and k=1 triangles:
%
%         *-----*
%        / \ 1 /
%       / 0 \ /
%      *-----*
%
%    Triangles are identified by a related (i,j,k) coordinate based 
%    on the (i,j) coordinates of its vertices:
%      If k = 0, the "ijk" triangle has vertices (i-1,j-1), (i,j-1), (i-1,j).
%      If k = 1, the "ijk" triangle has vertices (i,j),     (i-1,j), (i,j-1).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 November 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer IJK[3], the indices of the cell.
%
%    real R, a size factor for the triangles, between 0 and 1.
%
%    color COLOR, 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 circle is filled with this color.
%
%    string LABEL: an optional label.
%
  [ x, y ] = ijk_to_xy ( ijk );

  xm = sum ( x ) / 3.0;
  ym = sum ( y ) / 3.0;

  x = r * x + ( 1.0 - r ) * xm;
  y = r * y + ( 1.0 - r ) * ym;

  fill ( x, y, color );

  if ( 0 < length ( label ) )
    text ( xm, ym, label );
  end

  return
end

