-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathTextureBrush.cs
46 lines (37 loc) · 1.04 KB
/
TextureBrush.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace RGB.NET.Core;
/// <inheritdoc />
/// <summary>
/// Represents a brush drawing a texture.
/// </summary>
public sealed class TextureBrush : AbstractBrush
{
#region Properties & Fields
private ITexture _texture = ITexture.Empty;
/// <summary>
/// Gets or sets the texture drawn by this brush.
/// </summary>
public ITexture Texture
{
get => _texture;
set => SetProperty(ref _texture, value);
}
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="TextureBrush" /> class.
/// </summary>
/// <param name="texture">The texture drawn by this brush.</param>
public TextureBrush(ITexture texture)
{
this.Texture = texture;
}
#endregion
#region Methods
/// <inheritdoc />
protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget)
{
Rectangle normalizedRect = renderTarget.Rectangle / rectangle;
return Texture[normalizedRect];
}
#endregion
}