// ReSharper disable CollectionNeverUpdated.Global // ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBeProtected.Global // ReSharper disable ReturnTypeCanBeEnumerable.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable UnusedMember.Global using RGB.NET.Core; using RGB.NET.Presets.Helper; using RGB.NET.Presets.Textures.Gradients; namespace RGB.NET.Presets.Textures; /// /// /// Represents a texture drawing a linear gradient. /// public sealed class LinearGradientTexture : AbstractGradientTexture { #region Properties & Fields private Point _startPoint = new(0, 0.5f); /// /// Gets or sets the start (as percentage in the range [0..1]) of the drawn by this . (default: 0.0, 0.5) /// public Point StartPoint { get => _startPoint; set => SetProperty(ref _startPoint, value); } private Point _endPoint = new(1, 0.5f); /// /// Gets or sets the end (as percentage in the range [0..1]) of the drawn by this . (default: 1.0, 0.5) /// public Point EndPoint { get => _endPoint; set => SetProperty(ref _endPoint, value); } #endregion #region Constructor /// /// Initializes a new instance of the class. /// /// The size of the texture. /// The drawn by this . public LinearGradientTexture(Size size, IGradient gradient) : base(size, gradient) { } /// /// Initializes a new instance of the class. /// /// The size of the texture. /// The drawn by this . /// The start (as percentage in the range [0..1]). /// The end (as percentage in the range [0..1]). public LinearGradientTexture(Size size, IGradient gradient, Point startPoint, Point endPoint) : base(size, gradient) { this.StartPoint = startPoint; this.EndPoint = endPoint; } #endregion #region Methods /// protected override Color GetColor(in Point point) { float offset = GradientHelper.CalculateLinearGradientOffset(StartPoint, EndPoint, point); return Gradient.GetColor(offset); } #endregion }