Changed everything to use floats instead of doubles

This commit is contained in:
DarthAffe committed 2021-02-22 00:46:18 +01:00
1 parent 13afc29987
commit b328032df0
36 files changed
+433 -472

No files matched your search

@@ -96,23 +96,23 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
protected double ClipOffset(double offset)
protected float ClipOffset(float offset)
{
double max = GradientStops.Max(stop => stop.Offset);
float max = GradientStops.Max(stop => stop.Offset);
if (offset > max)
return max;
double min = GradientStops.Min(stop => stop.Offset);
float min = GradientStops.Min(stop => stop.Offset);
return offset < min ? min : offset;
}
/// <inheritdoc />
public abstract Color GetColor(double offset);
public abstract Color GetColor(float offset);
/// <inheritdoc />
public virtual void Move(double offset)
public virtual void Move(float offset)
{
offset /= 360.0;
offset /= 360.0f;
foreach (GradientStop gradientStop in GradientStops)
gradientStop.Offset += offset;
@@ -12,11 +12,11 @@ namespace RGB.NET.Presets.Textures.Gradients
{
#region Properties & Fields
private double _offset;
private float _offset;
/// <summary>
/// Gets or sets the percentage offset to place this <see cref="GradientStop"/>. This should be inside the range of [0..1] but it's not necessary.
/// </summary>
public double Offset
public float Offset
{
get => _offset;
set => SetProperty(ref _offset, value);
@@ -41,7 +41,7 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="offset">The percentage offset to place this <see cref="GradientStop"/>.</param>
/// <param name="color">The <see cref="Color"/> of the <see cref="GradientStop"/>.</param>
public GradientStop(double offset, Color color)
public GradientStop(float offset, Color color)
{
this.Offset = offset;
this.Color = color;
@@ -19,12 +19,12 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="offset">The percentage offset to take the <see cref="Color"/> from.</param>
/// <returns>The <see cref="Color"/> at the specific offset.</returns>
Color GetColor(double offset);
Color GetColor(float offset);
/// <summary>
/// Moves the <see cref="IGradient"/> by the provided offset.
/// </summary>
/// <param name="offset">The offset the <see cref="IGradient"/> should be moved.</param>
void Move(double offset);
void Move(float offset);
}
}
@@ -83,7 +83,7 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The <see cref="T:RGB.NET.Core.Color" /> at the specific offset.</returns>
public override Color GetColor(double offset)
public override Color GetColor(float offset)
{
if (GradientStops.Count == 0) return Color.Transparent;
if (GradientStops.Count == 1) return GradientStops[0].Color;
@@ -93,14 +93,14 @@ namespace RGB.NET.Presets.Textures.Gradients
(GradientStop gsBefore, GradientStop gsAfter) = GetEnclosingGradientStops(offset, _orderedGradientStops, WrapGradient);
double blendFactor = 0;
float blendFactor = 0;
if (!gsBefore.Offset.Equals(gsAfter.Offset))
blendFactor = ((offset - gsBefore.Offset) / (gsAfter.Offset - gsBefore.Offset));
double colA = ((gsAfter.Color.A - gsBefore.Color.A) * blendFactor) + gsBefore.Color.A;
double colR = ((gsAfter.Color.R - gsBefore.Color.R) * blendFactor) + gsBefore.Color.R;
double colG = ((gsAfter.Color.G - gsBefore.Color.G) * blendFactor) + gsBefore.Color.G;
double colB = ((gsAfter.Color.B - gsBefore.Color.B) * blendFactor) + gsBefore.Color.B;
float colA = ((gsAfter.Color.A - gsBefore.Color.A) * blendFactor) + gsBefore.Color.A;
float colR = ((gsAfter.Color.R - gsBefore.Color.R) * blendFactor) + gsBefore.Color.R;
float colG = ((gsAfter.Color.G - gsBefore.Color.G) * blendFactor) + gsBefore.Color.G;
float colB = ((gsAfter.Color.B - gsBefore.Color.B) * blendFactor) + gsBefore.Color.B;
return new Color(colA, colR, colG, colB);
}
@@ -112,7 +112,7 @@ namespace RGB.NET.Presets.Textures.Gradients
/// <param name="orderedStops">The ordered list of <see cref="GradientStop"/> to choose from.</param>
/// <param name="wrap">Bool indicating if the gradient should be wrapped or not.</param>
/// <returns></returns>
protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(double offset, LinkedList<GradientStop> orderedStops, bool wrap)
protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(float offset, LinkedList<GradientStop> orderedStops, bool wrap)
{
LinkedList<GradientStop> gradientStops = new(orderedStops);
@@ -17,21 +17,21 @@ namespace RGB.NET.Presets.Textures.Gradients
{
#region Properties & Fields
private double _startHue;
private float _startHue;
/// <summary>
/// Gets or sets the hue (in degrees) to start from.
/// </summary>
public double StartHue
public float StartHue
{
get => _startHue;
set => SetProperty(ref _startHue, value);
}
private double _endHue;
private float _endHue;
/// <summary>
/// Gets or sets the hue (in degrees) to end the with.
/// </summary>
public double EndHue
public float EndHue
{
get => _endHue;
set => SetProperty(ref _endHue, value);
@@ -53,7 +53,7 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="startHue">The hue (in degrees) to start from (default: 0)</param>
/// <param name="endHue">The hue (in degrees) to end with (default: 360)</param>
public RainbowGradient(double startHue = 0, double endHue = 360)
public RainbowGradient(float startHue = 0, float endHue = 360)
{
this.StartHue = startHue;
this.EndHue = endHue;
@@ -71,15 +71,15 @@ namespace RGB.NET.Presets.Textures.Gradients
/// </summary>
/// <param name="offset">The percentage offset to take the color from.</param>
/// <returns>The color at the specific offset.</returns>
public Color GetColor(double offset)
public Color GetColor(float offset)
{
double range = EndHue - StartHue;
double hue = StartHue + (range * offset);
float range = EndHue - StartHue;
float hue = StartHue + (range * offset);
return HSVColor.Create(hue, 1, 1);
}
/// <inheritdoc />
public void Move(double offset)
public void Move(float offset)
{
// RainbowGradient is calculated inverse
offset *= -1;