// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using CUE.NET.Devices.Generic;
using CUE.NET.Helper;
namespace CUE.NET.Gradients
{
///
/// Represents a rainbow gradient which circles through all colors of the HUE-color-space.
/// See as reference.
///
public class RainbowGradient : IGradient
{
#region Properties & Fields
///
/// Gets or sets the hue (in degrees) to start from.
///
public float StartHue { get; set; }
///
/// Gets or sets the hue (in degrees) to end the with.
///
public float EndHue { get; set; }
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The hue (in degrees) to start from (default: 0)
/// The hue (in degrees) to end with (default: 360)
public RainbowGradient(float startHue = 0f, float endHue = 360f)
{
this.StartHue = startHue;
this.EndHue = endHue;
}
#endregion
#region Methods
#endregion
///
/// Gets the color on the rainbow at the given offset.
///
/// The percentage offset to take the color from.
/// The color at the specific offset.
public CorsairColor GetColor(float offset)
{
float range = EndHue - StartHue;
float hue = (StartHue + (range * offset)) % 360f;
if (hue < 0)
hue += 360;
return ColorHelper.ColorFromHSV(hue, 1f, 1f);
}
}
}