From cfbbdc60691b536523989877dedcf8b9e1054b67 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sun, 21 Jul 2024 23:52:06 +0200 Subject: [PATCH] Changed ImageTexture Image to be public --- RGB.NET.Presets/Textures/ImageTexture.cs | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/RGB.NET.Presets/Textures/ImageTexture.cs b/RGB.NET.Presets/Textures/ImageTexture.cs index fc05b74..e63793a 100644 --- a/RGB.NET.Presets/Textures/ImageTexture.cs +++ b/RGB.NET.Presets/Textures/ImageTexture.cs @@ -7,13 +7,26 @@ namespace RGB.NET.Presets.Textures; /// /// -/// Represents a texture drawing an . +/// Represents a texture drawing an . /// public sealed class ImageTexture : ITexture { #region Properties & Fields - private readonly IImage _image; + private IImage _image; + + /// + /// The image drawn by this texture. + /// + public IImage Image + { + get => _image; + set + { + ArgumentNullException.ThrowIfNull(value); + _image = value; + } + } /// public Size Size { get; } @@ -26,7 +39,7 @@ public sealed class ImageTexture : ITexture int x = (int)MathF.Round((Size.Width - 1) * point.X.Clamp(0, 1)); int y = (int)MathF.Round((Size.Height - 1) * point.Y.Clamp(0, 1)); - return _image[x, y].ToColor(); + return Image[x, y].ToColor(); } } @@ -55,7 +68,7 @@ public sealed class ImageTexture : ITexture /// The with of the region. /// The height of the region. /// The sampled color. - public Color this[int x, int y, int width, int height] => _image[x, y, width, height].Average().ToColor(); + public Color this[int x, int y, int width, int height] => Image[x, y, width, height].Average().ToColor(); #endregion @@ -65,9 +78,11 @@ public sealed class ImageTexture : ITexture /// Initializes a new instance of the class. /// /// The image represented by the texture. +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public ImageTexture(IImage image) +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. { - this._image = image; + this.Image = image; Size = new Size(image.Width, image.Height); }