namespace RGB.NET.Core;
///
///
/// Represents a brush drawing a texture.
///
public class TextureBrush : AbstractBrush
{
#region Properties & Fields
private ITexture _texture = ITexture.Empty;
///
/// Gets or sets the texture drawn by this brush.
///
public ITexture Texture
{
get => _texture;
set => SetProperty(ref _texture, value);
}
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The texture drawn by this brush.
public TextureBrush(ITexture texture)
{
this.Texture = texture;
}
#endregion
#region Methods
///
protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget)
{
Rectangle normalizedRect = renderTarget.Rectangle / rectangle;
return Texture[normalizedRect];
}
#endregion
}