using RGB.NET.Core;
using RGB.NET.Presets.Textures.Gradients;
namespace RGB.NET.Presets.Decorators;
///
///
///
/// Represents a decorator which allows to move an by modifying his offset.
///
public class MoveGradientDecorator : AbstractUpdateAwareDecorator, IGradientDecorator
{
#region Properties & Fields
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
// ReSharper disable MemberCanBePrivate.Global
///
/// Gets or sets the direction the is moved.
/// True leads to an offset-increment (normaly moving to the right), false to an offset-decrement (normaly moving to the left).
///
public bool Direction { get; set; }
///
/// Gets or sets the speed of the movement in units per second.
/// The meaning of units differs for the different , but 360 units will always be one complete cycle:
/// : 360 unit = 1 offset.
/// : 1 unit = 1 degree.
///
public float Speed { get; set; }
// ReSharper restore MemberCanBePrivate.Global
// ReSharper restore AutoPropertyCanBeMadeGetOnly.Global
#endregion
#region Constructors
///
///
/// Initializes a new instance of the class.
///
/// The surface this decorator belongs to.
/// The speed of the movement in units per second.
/// The meaning of units differs for the different but 360 units will always be one complete cycle:
/// : 360 unit = 1 offset.
/// : 1 unit = 1 degree.
/// The direction the is moved.
/// True leads to an offset-increment (normaly moving to the right), false to an offset-decrement (normaly moving to the left).
public MoveGradientDecorator(RGBSurface surface, float speed = 180.0f, bool direction = true)
: base(surface)
{
this.Speed = speed;
this.Direction = direction;
}
#endregion
#region Methods
///
protected override void Update(double deltaTime)
{
float movement = Speed * (float)deltaTime;
if (!Direction)
movement = -movement;
foreach (IDecoratable decoratedObject in DecoratedObjects)
if (decoratedObject is IGradient gradient)
gradient.Move(movement);
}
#endregion
}