namespace Terminal.Gui;
///
/// Implementation of that uses a color gradient (including
/// radial, diagonal etc).
///
public class GradientFill : IFill
{
private Dictionary _map;
///
/// Creates a new instance of the class that can return
/// color for any point in the given using the provided
/// and .
///
///
///
///
public GradientFill (Rectangle area, Gradient gradient, GradientDirection direction)
{
_map = gradient.BuildCoordinateColorMapping (area.Height-1, area.Width-1, direction);
}
///
/// Returns the color to use for the given or Black if it
/// lies outside of the prepared gradient area (see constructor).
///
///
///
public Color GetColor (Point point)
{
if (_map.TryGetValue (point, out var color))
{
return color;
}
return new Color (0, 0, 0); // Default to black if point not found
}
}