diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs
index 40b0eec..53289c6 100644
--- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs
+++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs
@@ -19,7 +19,7 @@
{
if (!(obj is Color)) return false;
- (double a, double r, double g, double b) = ((Color)obj).GetRGB();
+ (float a, float r, float g, float b) = ((Color)obj).GetRGB();
return color.A.EqualsInTolerance(a) && color.R.EqualsInTolerance(r) && color.G.EqualsInTolerance(g) && color.B.EqualsInTolerance(b);
}
@@ -50,10 +50,10 @@
if (blendColor.A.EqualsInTolerance(1))
return blendColor;
- double resultA = (1.0 - ((1.0 - blendColor.A) * (1.0 - baseColor.A)));
- double resultR = (((blendColor.R * blendColor.A) / resultA) + ((baseColor.R * baseColor.A * (1.0 - blendColor.A)) / resultA));
- double resultG = (((blendColor.G * blendColor.A) / resultA) + ((baseColor.G * baseColor.A * (1.0 - blendColor.A)) / resultA));
- double resultB = (((blendColor.B * blendColor.A) / resultA) + ((baseColor.B * baseColor.A * (1.0 - blendColor.A)) / resultA));
+ float resultA = (1.0f - ((1.0f - blendColor.A) * (1.0f - baseColor.A)));
+ float resultR = (((blendColor.R * blendColor.A) / resultA) + ((baseColor.R * baseColor.A * (1.0f - blendColor.A)) / resultA));
+ float resultG = (((blendColor.G * blendColor.A) / resultA) + ((baseColor.G * baseColor.A * (1.0f - blendColor.A)) / resultA));
+ float resultB = (((blendColor.B * blendColor.A) / resultA) + ((baseColor.B * baseColor.A * (1.0f - blendColor.A)) / resultA));
return new Color(resultA, resultR, resultG, resultB);
}
diff --git a/RGB.NET.Core/Color/Color.cs b/RGB.NET.Core/Color/Color.cs
index e389f19..0948c47 100644
--- a/RGB.NET.Core/Color/Color.cs
+++ b/RGB.NET.Core/Color/Color.cs
@@ -32,22 +32,22 @@ namespace RGB.NET.Core
///
/// Gets the alpha component value of this as percentage in the range [0..1].
///
- public double A { get; }
+ public float A { get; }
///
/// Gets the red component value of this as percentage in the range [0..1].
///
- public double R { get; }
+ public float R { get; }
///
/// Gets the green component value of this as percentage in the range [0..1].
///
- public double G { get; }
+ public float G { get; }
///
/// Gets the blue component value of this as percentage in the range [0..1].
///
- public double B { get; }
+ public float B { get; }
#endregion
@@ -106,8 +106,8 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(double r, double g, double b)
- : this(1.0, r, g, b)
+ public Color(float r, float g, float b)
+ : this(1.0f, r, g, b)
{ }
///
@@ -117,7 +117,7 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(double a, byte r, byte g, byte b)
+ public Color(float a, byte r, byte g, byte b)
: this(a, r.GetPercentageFromByteValue(), g.GetPercentageFromByteValue(), b.GetPercentageFromByteValue())
{ }
@@ -128,7 +128,7 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(double a, int r, int g, int b)
+ public Color(float a, int r, int g, int b)
: this(a, (byte)r.Clamp(0, byte.MaxValue), (byte)g.Clamp(0, byte.MaxValue), (byte)b.Clamp(0, byte.MaxValue))
{ }
@@ -139,7 +139,7 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(int a, double r, double g, double b)
+ public Color(int a, float r, float g, float b)
: this((byte)a.Clamp(0, byte.MaxValue), r, g, b)
{ }
@@ -150,7 +150,7 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(byte a, double r, double g, double b)
+ public Color(byte a, float r, float g, float b)
: this(a.GetPercentageFromByteValue(), r, g, b)
{ }
@@ -161,7 +161,7 @@ namespace RGB.NET.Core
/// The red component value of this .
/// The green component value of this .
/// The blue component value of this .
- public Color(double a, double r, double g, double b)
+ public Color(float a, float r, float g, float b)
{
A = a.Clamp(0, 1);
R = r.Clamp(0, 1);
@@ -269,14 +269,14 @@ namespace RGB.NET.Core
///
/// The containing the components.
/// The color.
- public static implicit operator Color((double r, double g, double b) components) => new(components.r, components.g, components.b);
+ public static implicit operator Color((float r, float g, float b) components) => new(components.r, components.g, components.b);
///
/// Converts a of ARGB-components to a .
///
/// The containing the components.
/// The color.
- public static implicit operator Color((double a, double r, double g, double b) components) => new(components.a, components.r, components.g, components.b);
+ public static implicit operator Color((float a, float r, float g, float b) components) => new(components.a, components.r, components.g, components.b);
#endregion
}
diff --git a/RGB.NET.Core/Color/HSVColor.cs b/RGB.NET.Core/Color/HSVColor.cs
index 741a654..40c89c8 100644
--- a/RGB.NET.Core/Color/HSVColor.cs
+++ b/RGB.NET.Core/Color/HSVColor.cs
@@ -13,21 +13,21 @@ namespace RGB.NET.Core
///
///
///
- public static double GetHue(this Color color) => color.GetHSV().hue;
+ public static float GetHue(this Color color) => color.GetHSV().hue;
///
/// Gets the saturation component value (HSV-color space) of this in the range [0..1].
///
///
///
- public static double GetSaturation(this Color color) => color.GetHSV().saturation;
+ public static float GetSaturation(this Color color) => color.GetHSV().saturation;
///
/// Gets the value component value (HSV-color space) of this in the range [0..1].
///
///
///
- public static double GetValue(this Color color) => color.GetHSV().value;
+ public static float GetValue(this Color color) => color.GetHSV().value;
///
/// Gets the hue, saturation and value component values (HSV-color space) of this .
@@ -37,7 +37,7 @@ namespace RGB.NET.Core
///
///
///
- public static (double hue, double saturation, double value) GetHSV(this Color color)
+ public static (float hue, float saturation, float value) GetHSV(this Color color)
=> CaclulateHSVFromRGB(color.R, color.G, color.B);
#endregion
@@ -51,9 +51,9 @@ namespace RGB.NET.Core
/// The saturation value to add.
/// The value value to add.
/// The new color after the modification.
- public static Color AddHSV(this Color color, double hue = 0, double saturation = 0, double value = 0)
+ public static Color AddHSV(this Color color, float hue = 0, float saturation = 0, float value = 0)
{
- (double cHue, double cSaturation, double cValue) = color.GetHSV();
+ (float cHue, float cSaturation, float cValue) = color.GetHSV();
return Create(color.A, cHue + hue, cSaturation + saturation, cValue + value);
}
@@ -64,9 +64,9 @@ namespace RGB.NET.Core
/// The saturation value to subtract.
/// The value value to subtract.
/// The new color after the modification.
- public static Color SubtractHSV(this Color color, double hue = 0, double saturation = 0, double value = 0)
+ public static Color SubtractHSV(this Color color, float hue = 0, float saturation = 0, float value = 0)
{
- (double cHue, double cSaturation, double cValue) = color.GetHSV();
+ (float cHue, float cSaturation, float cValue) = color.GetHSV();
return Create(color.A, cHue - hue, cSaturation - saturation, cValue - value);
}
@@ -77,9 +77,9 @@ namespace RGB.NET.Core
/// The saturation value to multiply.
/// The value value to multiply.
/// The new color after the modification.
- public static Color MultiplyHSV(this Color color, double hue = 1, double saturation = 1, double value = 1)
+ public static Color MultiplyHSV(this Color color, float hue = 1, float saturation = 1, float value = 1)
{
- (double cHue, double cSaturation, double cValue) = color.GetHSV();
+ (float cHue, float cSaturation, float cValue) = color.GetHSV();
return Create(color.A, cHue * hue, cSaturation * saturation, cValue * value);
}
@@ -90,9 +90,9 @@ namespace RGB.NET.Core
/// The saturation value to divide.
/// The value value to divide.
/// The new color after the modification.
- public static Color DivideHSV(this Color color, double hue = 1, double saturation = 1, double value = 1)
+ public static Color DivideHSV(this Color color, float hue = 1, float saturation = 1, float value = 1)
{
- (double cHue, double cSaturation, double cValue) = color.GetHSV();
+ (float cHue, float cSaturation, float cValue) = color.GetHSV();
return Create(color.A, cHue / hue, cSaturation / saturation, cValue / value);
}
@@ -103,9 +103,9 @@ namespace RGB.NET.Core
/// The saturation value to set.
/// The value value to set.
/// The new color after the modification.
- public static Color SetHSV(this Color color, double? hue = null, double? saturation = null, double? value = null)
+ public static Color SetHSV(this Color color, float? hue = null, float? saturation = null, float? value = null)
{
- (double cHue, double cSaturation, double cValue) = color.GetHSV();
+ (float cHue, float cSaturation, float cValue) = color.GetHSV();
return Create(color.A, hue ?? cHue, saturation ?? cSaturation, value ?? cValue);
}
@@ -120,8 +120,8 @@ namespace RGB.NET.Core
/// The saturation component value of this .
/// The value component value of this .
/// The color created from the values.
- public static Color Create(double hue, double saturation, double value)
- => Create(1.0, hue, saturation, value);
+ public static Color Create(float hue, float saturation, float value)
+ => Create(1.0f, hue, saturation, value);
///
/// Creates a new instance of the struct using AHSV-Values.
@@ -131,8 +131,8 @@ namespace RGB.NET.Core
/// The saturation component value of this .
/// The value component value of this .
/// The color created from the values.
- public static Color Create(byte a, double hue, double saturation, double value)
- => Create((double)a / byte.MaxValue, hue, saturation, value);
+ public static Color Create(byte a, float hue, float saturation, float value)
+ => Create((float)a / byte.MaxValue, hue, saturation, value);
///
/// Creates a new instance of the struct using AHSV-Values.
@@ -142,8 +142,8 @@ namespace RGB.NET.Core
/// The saturation component value of this .
/// The value component value of this .
/// The color created from the values.
- public static Color Create(int a, double hue, double saturation, double value)
- => Create((double)a / byte.MaxValue, hue, saturation, value);
+ public static Color Create(int a, float hue, float saturation, float value)
+ => Create((float)a / byte.MaxValue, hue, saturation, value);
///
/// Creates a new instance of the struct using AHSV-Values.
@@ -153,9 +153,9 @@ namespace RGB.NET.Core
/// The saturation component value of this .
/// The value component value of this .
/// The color created from the values.
- public static Color Create(double a, double hue, double saturation, double value)
+ public static Color Create(float a, float hue, float saturation, float value)
{
- (double r, double g, double b) = CalculateRGBFromHSV(hue, saturation, value);
+ (float r, float g, float b) = CalculateRGBFromHSV(hue, saturation, value);
return new Color(a, r, g, b);
}
@@ -163,33 +163,33 @@ namespace RGB.NET.Core
#region Helper
- private static (double h, double s, double v) CaclulateHSVFromRGB(double r, double g, double b)
+ private static (float h, float s, float v) CaclulateHSVFromRGB(float r, float g, float b)
{
if (r.EqualsInTolerance(g) && g.EqualsInTolerance(b)) return (0, 0, r);
- double min = Math.Min(Math.Min(r, g), b);
- double max = Math.Max(Math.Max(r, g), b);
+ float min = Math.Min(Math.Min(r, g), b);
+ float max = Math.Max(Math.Max(r, g), b);
- double hue;
+ float hue;
if (max.EqualsInTolerance(min))
hue = 0;
else if (max.EqualsInTolerance(r)) // r is max
hue = (g - b) / (max - min);
else if (max.EqualsInTolerance(g)) // g is max
- hue = 2.0 + ((b - r) / (max - min));
+ hue = 2.0f + ((b - r) / (max - min));
else // b is max
- hue = 4.0 + ((r - g) / (max - min));
+ hue = 4.0f + ((r - g) / (max - min));
- hue *= 60.0;
+ hue *= 60.0f;
hue = hue.Wrap(0, 360);
- double saturation = max.EqualsInTolerance(0) ? 0 : 1.0 - (min / max);
- double value = Math.Max(r, Math.Max(g, b));
+ float saturation = max.EqualsInTolerance(0) ? 0 : 1.0f - (min / max);
+ float value = Math.Max(r, Math.Max(g, b));
return (hue, saturation, value);
}
- private static (double r, double g, double b) CalculateRGBFromHSV(double h, double s, double v)
+ private static (float r, float g, float b) CalculateRGBFromHSV(float h, float s, float v)
{
h = h.Wrap(0, 360);
s = s.Clamp(0, 1);
@@ -198,12 +198,12 @@ namespace RGB.NET.Core
if (s <= 0.0)
return (v, v, v);
- double hh = h / 60.0;
+ float hh = h / 60.0f;
int i = (int)hh;
- double ff = hh - i;
- double p = v * (1.0 - s);
- double q = v * (1.0 - (s * ff));
- double t = v * (1.0 - (s * (1.0 - ff)));
+ float ff = hh - i;
+ float p = v * (1.0f - s);
+ float q = v * (1.0f - (s * ff));
+ float t = v * (1.0f - (s * (1.0f - ff)));
return i switch
{
diff --git a/RGB.NET.Core/Color/RGBColor.cs b/RGB.NET.Core/Color/RGBColor.cs
index edb3e1f..17919ec 100644
--- a/RGB.NET.Core/Color/RGBColor.cs
+++ b/RGB.NET.Core/Color/RGBColor.cs
@@ -49,7 +49,7 @@ namespace RGB.NET.Core
///
///
///
- public static (double a, double r, double g, double b) GetRGB(this Color color)
+ public static (float a, float r, float g, float b) GetRGB(this Color color)
=> (color.A, color.R, color.G, color.B);
#endregion
@@ -75,7 +75,7 @@ namespace RGB.NET.Core
/// The green value to add.
/// The blue value to add.
/// The new color after the modification.
- public static Color AddRGB(this Color color, double r = 0, double g = 0, double b = 0)
+ public static Color AddRGB(this Color color, float r = 0, float g = 0, float b = 0)
=> new(color.A, color.R + r, color.G + g, color.B + b);
///
@@ -91,7 +91,7 @@ namespace RGB.NET.Core
///
/// The alpha value to add.
/// The new color after the modification.
- public static Color AddA(this Color color, double a)
+ public static Color AddA(this Color color, float a)
=> new(color.A + a, color.R, color.G, color.B);
#endregion
@@ -115,7 +115,7 @@ namespace RGB.NET.Core
/// The green value to subtract.
/// The blue value to subtract.
/// The new color after the modification.
- public static Color SubtractRGB(this Color color, double r = 0, double g = 0, double b = 0)
+ public static Color SubtractRGB(this Color color, float r = 0, float g = 0, float b = 0)
=> new(color.A, color.R - r, color.G - g, color.B - b);
///
@@ -131,7 +131,7 @@ namespace RGB.NET.Core
///
/// The alpha value to subtract.
/// The new color after the modification.
- public static Color SubtractA(this Color color, double aPercent)
+ public static Color SubtractA(this Color color, float aPercent)
=> new(color.A - aPercent, color.R, color.G, color.B);
#endregion
@@ -145,7 +145,7 @@ namespace RGB.NET.Core
/// The green value to multiply.
/// The blue value to multiply.
/// The new color after the modification.
- public static Color MultiplyRGB(this Color color, double r = 1, double g = 1, double b = 1)
+ public static Color MultiplyRGB(this Color color, float r = 1, float g = 1, float b = 1)
=> new(color.A, color.R * r, color.G * g, color.B * b);
///
@@ -153,7 +153,7 @@ namespace RGB.NET.Core
///
/// The alpha value to multiply.
/// The new color after the modification.
- public static Color MultiplyA(this Color color, double a)
+ public static Color MultiplyA(this Color color, float a)
=> new(color.A * a, color.R, color.G, color.B);
#endregion
@@ -167,7 +167,7 @@ namespace RGB.NET.Core
/// The green value to divide.
/// The blue value to divide.
/// The new color after the modification.
- public static Color DivideRGB(this Color color, double r = 1, double g = 1, double b = 1)
+ public static Color DivideRGB(this Color color, float r = 1, float g = 1, float b = 1)
=> new(color.A, color.R / r, color.G / g, color.B / b);
///
@@ -175,7 +175,7 @@ namespace RGB.NET.Core
///
/// The alpha value to divide.
/// The new color after the modification.
- public static Color DivideA(this Color color, double a)
+ public static Color DivideA(this Color color, float a)
=> new(color.A / a, color.R, color.G, color.B);
#endregion
@@ -209,7 +209,7 @@ namespace RGB.NET.Core
/// The green value to set.
/// The blue value to set.
/// The new color after the modification.
- public static Color SetRGB(this Color color, double? r = null, double? g = null, double? b = null)
+ public static Color SetRGB(this Color color, float? r = null, float? g = null, float? b = null)
=> new(color.A, r ?? color.R, g ?? color.G, b ?? color.B);
///
@@ -224,7 +224,7 @@ namespace RGB.NET.Core
///
/// The alpha value to set.
/// The new color after the modification.
- public static Color SetA(this Color color, double a) => new(a, color.R, color.G, color.B);
+ public static Color SetA(this Color color, float a) => new(a, color.R, color.G, color.B);
#endregion
diff --git a/RGB.NET.Core/Extensions/MathExtensions.cs b/RGB.NET.Core/Extensions/MathExtensions.cs
index 0a9fb88..d47db3f 100644
--- a/RGB.NET.Core/Extensions/MathExtensions.cs
+++ b/RGB.NET.Core/Extensions/MathExtensions.cs
@@ -4,16 +4,16 @@ using System.Runtime.CompilerServices;
namespace RGB.NET.Core
{
///
- /// Offers some extensions and helper-methods for the work with doubles
+ /// Offers some extensions and helper-methods for the work with floats
///
- public static class DoubleExtensions
+ public static class FloatExtensions
{
#region Constants
///
/// Defines the precision RGB.NET processes floating point comparisons in.
///
- public const double TOLERANCE = 1E-10;
+ public const float TOLERANCE = 1E-10f;
#endregion
@@ -26,7 +26,7 @@ namespace RGB.NET.Core
/// The first value to compare.
/// true if the difference is smaller than the ; otherwise, false.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool EqualsInTolerance(this double value1, double value2) => Math.Abs(value1 - value2) < TOLERANCE;
+ public static bool EqualsInTolerance(this float value1, float value2) => Math.Abs(value1 - value2) < TOLERANCE;
///
/// Clamps the provided value to be bigger or equal min and smaller or equal max.
@@ -36,7 +36,7 @@ namespace RGB.NET.Core
/// The higher value of the range the value is clamped to.
/// The clamped value.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static double Clamp(this double value, double min, double max)
+ public static float Clamp(this float value, float min, float max)
{
// ReSharper disable ConvertIfStatementToReturnStatement - I'm not sure why, but inlining this statement reduces performance by ~10%
if (value < min) return min;
@@ -70,9 +70,9 @@ namespace RGB.NET.Core
/// The higher value of the range the value is wrapped into.
/// The wrapped value.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static double Wrap(this double value, double min, double max)
+ public static float Wrap(this float value, float min, float max)
{
- double range = max - min;
+ float range = max - min;
while (value >= max)
value -= range;
@@ -84,17 +84,17 @@ namespace RGB.NET.Core
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static byte GetByteValueFromPercentage(this double percentage)
+ public static byte GetByteValueFromPercentage(this float percentage)
{
- if (double.IsNaN(percentage)) return 0;
+ if (float.IsNaN(percentage)) return 0;
- percentage = percentage.Clamp(0, 1.0);
+ percentage = percentage.Clamp(0, 1.0f);
return (byte)(percentage >= 1.0 ? 255 : percentage * 256.0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static double GetPercentageFromByteValue(this byte value)
- => ((double)value) / byte.MaxValue;
+ public static float GetPercentageFromByteValue(this byte value)
+ => ((float)value) / byte.MaxValue;
#endregion
}
diff --git a/RGB.NET.Core/Extensions/PointExtensions.cs b/RGB.NET.Core/Extensions/PointExtensions.cs
index 9766bf3..00436c1 100644
--- a/RGB.NET.Core/Extensions/PointExtensions.cs
+++ b/RGB.NET.Core/Extensions/PointExtensions.cs
@@ -13,7 +13,7 @@ namespace RGB.NET.Core
/// The x-ammount to move.
/// The y-ammount to move.
/// The new location of the point.
- public static Point Translate(this Point point, double x = 0, double y = 0) => new(point.X + x, point.Y + y);
+ public static Point Translate(this Point point, float x = 0, float y = 0) => new(point.X + x, point.Y + y);
///
/// Rotates the specified by the given amuont around the given origin.
@@ -24,8 +24,8 @@ namespace RGB.NET.Core
/// The new location of the point.
public static Point Rotate(this Point point, Rotation rotation, Point origin = new())
{
- double sin = Math.Sin(rotation.Radians);
- double cos = Math.Cos(rotation.Radians);
+ float sin = MathF.Sin(rotation.Radians);
+ float cos = MathF.Cos(rotation.Radians);
point = new Point(point.X - origin.X, point.Y - origin.Y);
point = new Point((point.X * cos) - (point.Y * sin), (point.X * sin) + (point.Y * cos));
diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs
index f14ccff..634c3f6 100644
--- a/RGB.NET.Core/Extensions/RectangleExtensions.cs
+++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs
@@ -20,7 +20,7 @@ namespace RGB.NET.Core
/// The rectangle to modify.
/// The new x-location of the rectangle.
/// The modified .
- public static Rectangle SetX(this Rectangle rect, double x) => new(new Point(x, rect.Location.Y), rect.Size);
+ public static Rectangle SetX(this Rectangle rect, float x) => new(new Point(x, rect.Location.Y), rect.Size);
///
/// Sets the of the of the given rectangle.
@@ -28,7 +28,7 @@ namespace RGB.NET.Core
/// The rectangle to modify.
/// The new y-location of the rectangle.
/// The modified .
- public static Rectangle SetY(this Rectangle rect, double y) => new(new Point(rect.Location.X, y), rect.Size);
+ public static Rectangle SetY(this Rectangle rect, float y) => new(new Point(rect.Location.X, y), rect.Size);
///
/// Sets the of the given rectangle.
@@ -44,7 +44,7 @@ namespace RGB.NET.Core
/// The rectangle to modify.
/// The new width of the rectangle.
/// The modified .
- public static Rectangle SetWidth(this Rectangle rect, double width) => new(rect.Location, new Size(width, rect.Size.Height));
+ public static Rectangle SetWidth(this Rectangle rect, float width) => new(rect.Location, new Size(width, rect.Size.Height));
///
/// Sets the of the of the given rectangle.
@@ -52,14 +52,14 @@ namespace RGB.NET.Core
/// The rectangle to modify.
/// The new height of the rectangle.
/// The modified .
- public static Rectangle SetHeight(this Rectangle rect, double height) => new(rect.Location, new Size(rect.Size.Width, height));
+ public static Rectangle SetHeight(this Rectangle rect, float height) => new(rect.Location, new Size(rect.Size.Width, height));
///
/// Calculates the percentage of intersection of a rectangle.
///
/// The intersecting rectangle.
/// The percentage of intersection.
- public static double CalculateIntersectPercentage(this Rectangle rect, in Rectangle intersectingRect)
+ public static float CalculateIntersectPercentage(this Rectangle rect, in Rectangle intersectingRect)
{
if (rect.IsEmpty || intersectingRect.IsEmpty) return 0;
@@ -74,11 +74,11 @@ namespace RGB.NET.Core
/// A new representing the intersection this and the one provided as parameter.
public static Rectangle CalculateIntersection(this Rectangle rect, in Rectangle intersectingRectangle)
{
- double x1 = Math.Max(rect.Location.X, intersectingRectangle.Location.X);
- double x2 = Math.Min(rect.Location.X + rect.Size.Width, intersectingRectangle.Location.X + intersectingRectangle.Size.Width);
+ float x1 = Math.Max(rect.Location.X, intersectingRectangle.Location.X);
+ float x2 = Math.Min(rect.Location.X + rect.Size.Width, intersectingRectangle.Location.X + intersectingRectangle.Size.Width);
- double y1 = Math.Max(rect.Location.Y, intersectingRectangle.Location.Y);
- double y2 = Math.Min(rect.Location.Y + rect.Size.Height, intersectingRectangle.Location.Y + intersectingRectangle.Size.Height);
+ float y1 = Math.Max(rect.Location.Y, intersectingRectangle.Location.Y);
+ float y2 = Math.Min(rect.Location.Y + rect.Size.Height, intersectingRectangle.Location.Y + intersectingRectangle.Size.Height);
if ((x2 >= x1) && (y2 >= y1))
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
@@ -99,7 +99,7 @@ namespace RGB.NET.Core
/// The X-location to test.
/// The Y-location to test.
/// true if the rectangle contains the given coordinates; otherwise false.
- public static bool Contains(this Rectangle rect, double x, double y) => (rect.Location.X <= x) && (x < (rect.Location.X + rect.Size.Width))
+ public static bool Contains(this Rectangle rect, float x, float y) => (rect.Location.X <= x) && (x < (rect.Location.X + rect.Size.Width))
&& (rect.Location.Y <= y) && (y < (rect.Location.Y + rect.Size.Height));
///
@@ -125,7 +125,7 @@ namespace RGB.NET.Core
/// The x-ammount to move.
/// The y-ammount to move.
/// The moved rectangle.
- public static Rectangle Translate(this Rectangle rect, double x = 0, double y = 0) => new(rect.Location.Translate(x, y), rect.Size);
+ public static Rectangle Translate(this Rectangle rect, float x = 0, float y = 0) => new(rect.Location.Translate(x, y), rect.Size);
///
/// Rotates the specified by the given amuont around the given origin.
@@ -150,8 +150,8 @@ namespace RGB.NET.Core
new(rect.Location.X, rect.Location.Y + rect.Size.Height), // bottom right
};
- double sin = Math.Sin(rotation.Radians);
- double cos = Math.Cos(rotation.Radians);
+ float sin = MathF.Sin(rotation.Radians);
+ float cos = MathF.Cos(rotation.Radians);
for (int i = 0; i < points.Length; i++)
{
diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs
index d546994..aa533f4 100644
--- a/RGB.NET.Core/Positioning/Point.cs
+++ b/RGB.NET.Core/Positioning/Point.cs
@@ -16,7 +16,7 @@ namespace RGB.NET.Core
///
/// Gets a [NaN,NaN]-Point.
///
- public static Point Invalid => new(double.NaN, double.NaN);
+ public static Point Invalid => new(float.NaN, float.NaN);
#endregion
@@ -25,12 +25,12 @@ namespace RGB.NET.Core
///
/// Gets the X-position of this .
///
- public double X { get; }
+ public float X { get; }
///
/// Gets the Y-position of this .
///
- public double Y { get; }
+ public float Y { get; }
#endregion
@@ -41,7 +41,7 @@ namespace RGB.NET.Core
///
/// The value used for the X-position.
/// The value used for the Y-position.
- public Point(double x, double y)
+ public Point(float x, float y)
{
this.X = x;
this.Y = y;
@@ -67,8 +67,8 @@ namespace RGB.NET.Core
if (!(obj is Point)) return false;
Point comparePoint = (Point)obj;
- return ((double.IsNaN(X) && double.IsNaN(comparePoint.X)) || X.EqualsInTolerance(comparePoint.X))
- && ((double.IsNaN(Y) && double.IsNaN(comparePoint.Y)) || Y.EqualsInTolerance(comparePoint.Y));
+ return ((float.IsNaN(X) && float.IsNaN(comparePoint.X)) || X.EqualsInTolerance(comparePoint.X))
+ && ((float.IsNaN(Y) && float.IsNaN(comparePoint.Y)) || Y.EqualsInTolerance(comparePoint.Y));
}
///
diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs
index fc94eb9..eddffb5 100644
--- a/RGB.NET.Core/Positioning/Rectangle.cs
+++ b/RGB.NET.Core/Positioning/Rectangle.cs
@@ -35,7 +35,7 @@ namespace RGB.NET.Core
/// Gets a bool indicating if both, the width and the height of the rectangle is greater than zero.
/// True if the rectangle has a width or a height of zero; otherwise, false.
///
- public bool IsEmpty => (Size.Width <= DoubleExtensions.TOLERANCE) || (Size.Height <= DoubleExtensions.TOLERANCE);
+ public bool IsEmpty => (Size.Width <= FloatExtensions.TOLERANCE) || (Size.Height <= FloatExtensions.TOLERANCE);
#endregion
@@ -49,7 +49,7 @@ namespace RGB.NET.Core
/// The y-value of the -position of this .
/// The width of the of this .
/// The height of the of this .
- public Rectangle(double x, double y, double width, double height)
+ public Rectangle(float x, float y, float width, float height)
: this(new Point(x, y), new Size(width, height))
{ }
@@ -70,7 +70,7 @@ namespace RGB.NET.Core
this.Location = location;
this.Size = size;
- Center = new Point(Location.X + (Size.Width / 2.0), Location.Y + (Size.Height / 2.0));
+ Center = new Point(Location.X + (Size.Width / 2.0f), Location.Y + (Size.Height / 2.0f));
}
///
@@ -91,10 +91,10 @@ namespace RGB.NET.Core
public Rectangle(IEnumerable rectangles)
{
bool hasPoint = false;
- double posX = double.MaxValue;
- double posY = double.MaxValue;
- double posX2 = double.MinValue;
- double posY2 = double.MinValue;
+ float posX = float.MaxValue;
+ float posY = float.MaxValue;
+ float posX2 = float.MinValue;
+ float posY2 = float.MinValue;
foreach (Rectangle rectangle in rectangles)
{
@@ -108,7 +108,7 @@ namespace RGB.NET.Core
(Point location, Size size) = hasPoint ? InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)) : InitializeFromPoints(new Point(0, 0), new Point(0, 0));
Location = location;
Size = size;
- Center = new Point(Location.X + (Size.Width / 2.0), Location.Y + (Size.Height / 2.0));
+ Center = new Point(Location.X + (Size.Width / 2.0f), Location.Y + (Size.Height / 2.0f));
}
///
@@ -131,10 +131,10 @@ namespace RGB.NET.Core
: this()
{
bool hasPoint = false;
- double posX = double.MaxValue;
- double posY = double.MaxValue;
- double posX2 = double.MinValue;
- double posY2 = double.MinValue;
+ float posX = float.MaxValue;
+ float posY = float.MaxValue;
+ float posX2 = float.MinValue;
+ float posY2 = float.MinValue;
foreach (Point point in points)
{
@@ -149,7 +149,7 @@ namespace RGB.NET.Core
Location = location;
Size = size;
- Center = new Point(Location.X + (Size.Width / 2.0), Location.Y + (Size.Height / 2.0));
+ Center = new Point(Location.X + (Size.Width / 2.0f), Location.Y + (Size.Height / 2.0f));
}
#endregion
@@ -158,10 +158,10 @@ namespace RGB.NET.Core
private static (Point location, Size size) InitializeFromPoints(Point point1, Point point2)
{
- double posX = Math.Min(point1.X, point2.X);
- double posY = Math.Min(point1.Y, point2.Y);
- double width = Math.Max(point1.X, point2.X) - posX;
- double height = Math.Max(point1.Y, point2.Y) - posY;
+ float posX = Math.Min(point1.X, point2.X);
+ float posY = Math.Min(point1.Y, point2.Y);
+ float width = Math.Max(point1.X, point2.X) - posX;
+ float height = Math.Max(point1.Y, point2.Y) - posY;
return (new Point(posX, posY), new Size(width, height));
}
@@ -225,8 +225,8 @@ namespace RGB.NET.Core
// DarthAffe 20.02.2021: Used for normalization
public static Rectangle operator /(Rectangle rectangle1, Rectangle rectangle2)
{
- double x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X);
- double y = rectangle1.Location.Y / (rectangle2.Size.Height - rectangle2.Location.Y);
+ float x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X);
+ float y = rectangle1.Location.Y / (rectangle2.Size.Height - rectangle2.Location.Y);
Size size = rectangle1.Size / rectangle2.Size;
return new Rectangle(new Point(x, y), size);
}
diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs
index 623f64a..d0de9d2 100644
--- a/RGB.NET.Core/Positioning/Rotation.cs
+++ b/RGB.NET.Core/Positioning/Rotation.cs
@@ -14,9 +14,9 @@ namespace RGB.NET.Core
{
#region Constants
- private const double TWO_PI = Math.PI * 2.0;
- private const double RADIANS_DEGREES_CONVERSION = 180.0 / Math.PI;
- private const double DEGREES_RADIANS_CONVERSION = Math.PI / 180.0;
+ private const float TWO_PI = MathF.PI * 2.0f;
+ private const float RADIANS_DEGREES_CONVERSION = 180.0f / MathF.PI;
+ private const float DEGREES_RADIANS_CONVERSION = MathF.PI / 180.0f;
#endregion
@@ -25,12 +25,12 @@ namespace RGB.NET.Core
///
/// Gets the angle in degrees.
///
- public double Degrees { get; }
+ public float Degrees { get; }
///
/// Gets the angle in radians.
///
- public double Radians { get; }
+ public float Radians { get; }
///
/// Gets a bool indicating if the rotation is > 0.
@@ -45,13 +45,13 @@ namespace RGB.NET.Core
/// Initializes a new instance of the class using the provided values.
///
/// The rotation in degrees.
- public Rotation(double degrees)
+ public Rotation(float degrees)
: this(degrees, degrees * DEGREES_RADIANS_CONVERSION)
{ }
- private Rotation(double degrees, double radians)
+ private Rotation(float degrees, float radians)
{
- this.Degrees = degrees % 360.0;
+ this.Degrees = degrees % 360.0f;
this.Radians = radians % TWO_PI;
}
@@ -64,14 +64,14 @@ namespace RGB.NET.Core
///
/// The angle in degrees.
/// The new rotation.
- public static Rotation FromDegrees(double degrees) => new(degrees);
+ public static Rotation FromDegrees(float degrees) => new(degrees);
///
/// Creates a new Rotation out of the given radian-angle.
///
/// The angle in radians.
/// The new rotation.
- public static Rotation FromRadians(double radians) => new(radians * RADIANS_DEGREES_CONVERSION, radians);
+ public static Rotation FromRadians(float radians) => new(radians * RADIANS_DEGREES_CONVERSION, radians);
///
/// Tests whether the specified is equivalent to this .
@@ -119,7 +119,7 @@ namespace RGB.NET.Core
/// The .
/// The value to add.
/// A new representing the addition of the and the provided value.
- public static Rotation operator +(Rotation rotation, double value) => new(rotation.Degrees + value);
+ public static Rotation operator +(Rotation rotation, float value) => new(rotation.Degrees + value);
///
/// Returns a new representing the subtraction of the and the provided value.
@@ -127,7 +127,7 @@ namespace RGB.NET.Core
/// The .
/// The value to substract.
/// A new representing the subtraction of the and the provided value.
- public static Rotation operator -(Rotation rotation, double value) => new(rotation.Degrees - value);
+ public static Rotation operator -(Rotation rotation, float value) => new(rotation.Degrees - value);
///
/// Returns a new representing the multiplication of the and the provided value.
@@ -135,7 +135,7 @@ namespace RGB.NET.Core
/// The .
/// The value to multiply with.
/// A new representing the multiplication of the and the provided value.
- public static Rotation operator *(Rotation rotation, double value) => new(rotation.Degrees * value);
+ public static Rotation operator *(Rotation rotation, float value) => new(rotation.Degrees * value);
///
/// Returns a new representing the division of the and the provided value.
@@ -143,19 +143,19 @@ namespace RGB.NET.Core
/// The .
/// The value to device with.
/// A new representing the division of the and the provided value.
- public static Rotation operator /(Rotation rotation, double value) => value.EqualsInTolerance(0) ? new Rotation(0) : new Rotation(rotation.Degrees / value);
+ public static Rotation operator /(Rotation rotation, float value) => value.EqualsInTolerance(0) ? new Rotation(0) : new Rotation(rotation.Degrees / value);
///
- /// Converts a double to a .
+ /// Converts a float to a .
///
/// The rotation in degrees to convert.
- public static implicit operator Rotation(double rotation) => new(rotation);
+ public static implicit operator Rotation(float rotation) => new(rotation);
///
- /// Converts to a double representing the rotation in degrees.
+ /// Converts to a float representing the rotation in degrees.
///
/// The rotatio to convert.
- public static implicit operator double(Rotation rotation) => rotation.Degrees;
+ public static implicit operator float(Rotation rotation) => rotation.Degrees;
#endregion
}
diff --git a/RGB.NET.Core/Positioning/Scale.cs b/RGB.NET.Core/Positioning/Scale.cs
index b12af17..1923bf7 100644
--- a/RGB.NET.Core/Positioning/Scale.cs
+++ b/RGB.NET.Core/Positioning/Scale.cs
@@ -16,12 +16,12 @@ namespace RGB.NET.Core
///
/// Gets the horizontal scaling value.
///
- public double Horizontal { get; }
+ public float Horizontal { get; }
///
/// Gets the vertical scaling value.
///
- public double Vertical { get; }
+ public float Vertical { get; }
#endregion
@@ -31,7 +31,7 @@ namespace RGB.NET.Core
/// Initializes a new instance of the class using the provided values.
///
/// The value used for horizontal and vertical scaling. 0 if not set.
- public Scale(double scale = 1.0) : this(scale, scale)
+ public Scale(float scale = 1.0f) : this(scale, scale)
{ }
///
@@ -39,7 +39,7 @@ namespace RGB.NET.Core
///
/// The value used for horizontal scaling.
/// The value used for vertical scaling.
- public Scale(double horizontal, double vertical)
+ public Scale(float horizontal, float vertical)
{
this.Horizontal = horizontal;
this.Vertical = vertical;
@@ -74,7 +74,7 @@ namespace RGB.NET.Core
///
/// The horizontal scaling value.
/// The vertical scaling value.
- public void Deconstruct(out double horizontalScale, out double verticalScale)
+ public void Deconstruct(out float horizontalScale, out float verticalScale)
{
horizontalScale = Horizontal;
verticalScale = Vertical;
@@ -106,7 +106,7 @@ namespace RGB.NET.Core
/// The .
/// The value to add.
/// A new representing the addition of the and the provided value.
- public static Scale operator +(Scale scale, double value) => new(scale.Horizontal + value, scale.Vertical + value);
+ public static Scale operator +(Scale scale, float value) => new(scale.Horizontal + value, scale.Vertical + value);
///
/// Returns a new representing the subtraction of the and the provided value.
@@ -114,7 +114,7 @@ namespace RGB.NET.Core
/// The .
/// The value to substract.
/// A new representing the subtraction of the and the provided value.
- public static Scale operator -(Scale scale, double value) => new(scale.Horizontal - value, scale.Vertical - value);
+ public static Scale operator -(Scale scale, float value) => new(scale.Horizontal - value, scale.Vertical - value);
///
/// Returns a new representing the multiplication of the and the provided value.
@@ -122,7 +122,7 @@ namespace RGB.NET.Core
/// The .
/// The value to multiply with.
/// A new representing the multiplication of the and the provided value.
- public static Scale operator *(Scale scale, double value) => new(scale.Horizontal * value, scale.Vertical * value);
+ public static Scale operator *(Scale scale, float value) => new(scale.Horizontal * value, scale.Vertical * value);
///
/// Returns a new representing the division of the and the provided value.
@@ -130,14 +130,14 @@ namespace RGB.NET.Core
/// The .
/// The value to device with.
/// A new representing the division of the and the provided value.
- public static Scale operator /(Scale scale, double value) => value.EqualsInTolerance(0) ? new Scale(0) : new Scale(scale.Horizontal / value, scale.Vertical / value);
+ public static Scale operator /(Scale scale, float value) => value.EqualsInTolerance(0) ? new Scale(0) : new Scale(scale.Horizontal / value, scale.Vertical / value);
///
- /// Converts a double to a .
+ /// Converts a float to a .
///
/// The scale value to convert.
- public static implicit operator Scale(double scale) => new(scale);
+ public static implicit operator Scale(float scale) => new(scale);
#endregion
}
diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs
index 7ed7887..690dc6b 100644
--- a/RGB.NET.Core/Positioning/Size.cs
+++ b/RGB.NET.Core/Positioning/Size.cs
@@ -16,7 +16,7 @@ namespace RGB.NET.Core
///
/// Gets a [NaN,NaN]-Size.
///
- public static Size Invalid => new(double.NaN, double.NaN);
+ public static Size Invalid => new(float.NaN, float.NaN);
#endregion
@@ -25,12 +25,12 @@ namespace RGB.NET.Core
///
/// Gets or sets the width component value of this .
///
- public double Width { get; }
+ public float Width { get; }
///
/// Gets or sets the height component value of this .
///
- public double Height { get; }
+ public float Height { get; }
#endregion
@@ -41,7 +41,7 @@ namespace RGB.NET.Core
/// Initializes a new instance of the using the provided size to define a square.
///
/// The size used for the component value and the component value.
- public Size(double size)
+ public Size(float size)
: this(size, size)
{ }
@@ -50,7 +50,7 @@ namespace RGB.NET.Core
///
/// The size used for the component value.
/// The size used for the component value.
- public Size(double width, double height)
+ public Size(float width, float height)
{
this.Width = width;
this.Height = height;
@@ -75,9 +75,9 @@ namespace RGB.NET.Core
{
if (!(obj is Size size)) return false;
- (double width, double height) = size;
- return ((double.IsNaN(Width) && double.IsNaN(width)) || Width.EqualsInTolerance(width))
- && ((double.IsNaN(Height) && double.IsNaN(height)) || Height.EqualsInTolerance(height));
+ (float width, float height) = size;
+ return ((float.IsNaN(Width) && float.IsNaN(width)) || Width.EqualsInTolerance(width))
+ && ((float.IsNaN(Height) && float.IsNaN(height)) || Height.EqualsInTolerance(height));
}
///
@@ -99,7 +99,7 @@ namespace RGB.NET.Core
///
/// The width.
/// The height.
- public void Deconstruct(out double width, out double height)
+ public void Deconstruct(out float width, out float height)
{
width = Width;
height = Height;
@@ -163,7 +163,7 @@ namespace RGB.NET.Core
/// The .
/// The factor by which the should be multiplied.
/// A new representing the multiplication of the and the provided factor.
- public static Size operator *(Size size, double factor) => new(size.Width * factor, size.Height * factor);
+ public static Size operator *(Size size, float factor) => new(size.Width * factor, size.Height * factor);
///
/// Returns a new representing the division of the two provided .
@@ -181,7 +181,7 @@ namespace RGB.NET.Core
/// The .
/// The factor by which the should be divided.
/// A new representing the division of the and the provided factor.
- public static Size operator /(Size size, double factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor);
+ public static Size operator /(Size size, float factor) => factor.EqualsInTolerance(0) ? Invalid : new Size(size.Width / factor, size.Height / factor);
///
/// Returns a new representing the multiplication of the and the given .
diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs
index 417acc5..58208a3 100644
--- a/RGB.NET.Core/RGBSurface.cs
+++ b/RGB.NET.Core/RGBSurface.cs
@@ -324,7 +324,7 @@ namespace RGB.NET.Core
///
public void AlignDevices()
{
- double posX = 0;
+ float posX = 0;
foreach (IRGBDevice device in Devices)
{
device.Location += new Point(posX, 0);
diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
index 25e29bf..77a39e6 100644
--- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
+++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs
@@ -23,10 +23,10 @@ namespace RGB.NET.Core
public RenderMode CalculationMode { get; set; } = RenderMode.Relative;
///
- public double Brightness { get; set; }
+ public float Brightness { get; set; }
///
- public double Opacity { get; set; }
+ public float Opacity { get; set; }
#endregion
@@ -37,7 +37,7 @@ namespace RGB.NET.Core
///
/// The overall percentage brightness of the brush. (default: 1.0)
/// The overall percentage opacity of the brush. (default: 1.0)
- protected AbstractBrush(double brightness = 1, double opacity = 1)
+ protected AbstractBrush(float brightness = 1, float opacity = 1)
{
this.Brightness = brightness;
this.Opacity = opacity;
diff --git a/RGB.NET.Core/Rendering/Brushes/IBrush.cs b/RGB.NET.Core/Rendering/Brushes/IBrush.cs
index 3d2f449..f2509af 100644
--- a/RGB.NET.Core/Rendering/Brushes/IBrush.cs
+++ b/RGB.NET.Core/Rendering/Brushes/IBrush.cs
@@ -24,12 +24,12 @@ namespace RGB.NET.Core
///
/// Gets or sets the overall percentage brightness of the .
///
- double Brightness { get; set; }
+ float Brightness { get; set; }
///
/// Gets or sets the overall percentage opacity of the .
///
- double Opacity { get; set; }
+ float Opacity { get; set; }
///
/// Performs the render pass of the and calculates the raw for all requested .
diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageSampler.cs
index 92670da..c9e95ce 100644
--- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageSampler.cs
+++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageSampler.cs
@@ -1,75 +1,36 @@
-using System;
-
-namespace RGB.NET.Core
+namespace RGB.NET.Core
{
public class AverageSampler : ISampler
{
#region Properties & Fields
- private Func, int, int, int, int, Color> _sampleMethod = SampleWithoutAlpha;
-
- private bool _sampleAlpha;
- public bool SampleAlpha
- {
- get => _sampleAlpha;
- set
- {
- _sampleAlpha = value;
- _sampleMethod = value ? SampleWithAlpha : SampleWithoutAlpha;
- }
- }
+ public bool SampleAlpha { get; set; }
#endregion
#region Methods
- public Color SampleColor(in ReadOnlyMemory data, int x, int y, int width, int height) => _sampleMethod(data, x, y, width, height);
-
- private static Color SampleWithAlpha(ReadOnlyMemory data, int x, int y, int width, int height)
+ public Color SampleColor(int x, int y, int width, int height, GetColor getColor)
{
- ReadOnlySpan span = data.Span;
-
+ int maxX = x + width;
int maxY = y + height;
int count = width * height;
- double a = 0, r = 0, g = 0, b = 0;
+ if (count == 0) return Color.Transparent;
+
+ float a = 0, r = 0, g = 0, b = 0;
for (int yPos = y; yPos < maxY; yPos++)
- {
- ReadOnlySpan line = span.Slice((yPos * width) + x, width);
- foreach (Color color in line)
+ for (int xPos = x; xPos < maxX; xPos++)
{
+ Color color = getColor(x, y);
a += color.A;
r += color.R;
g += color.G;
b += color.B;
}
- }
- if (count == 0) return Color.Transparent;
-
- return new Color(a / count, r / count, g / count, b / count);
- }
-
- private static Color SampleWithoutAlpha(ReadOnlyMemory data, int x, int y, int width, int height)
- {
- ReadOnlySpan span = data.Span;
-
- int maxY = y + height;
- int count = width * height;
- double r = 0, g = 0, b = 0;
- for (int yPos = y; yPos < maxY; yPos++)
- {
- ReadOnlySpan line = span.Slice((yPos * width) + x, width);
- foreach (Color color in line)
- {
- r += color.R;
- g += color.G;
- b += color.B;
- }
- }
-
- if (count == 0) return Color.Transparent;
-
- return new Color(r / count, g / count, b / count);
+ return SampleAlpha
+ ? new Color(a / count, r / count, g / count, b / count)
+ : new Color(r / count, g / count, b / count);
}
#endregion
diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs
index fd2ea52..2d9fced 100644
--- a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs
+++ b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs
@@ -1,9 +1,9 @@
-using System;
-
-namespace RGB.NET.Core
+namespace RGB.NET.Core
{
+ public delegate Color GetColor(int x, int y);
+
public interface ISampler
{
- Color SampleColor(in ReadOnlyMemory data, int x, int y, int width, int height);
+ Color SampleColor(int x, int y, int width, int height, GetColor getColorFunc);
}
}
diff --git a/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs b/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs
index d823f09..3a50788 100644
--- a/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs
+++ b/RGB.NET.Devices.Corsair/Helper/NativeExtensions.cs
@@ -8,10 +8,10 @@ namespace RGB.NET.Devices.Corsair
internal static Rectangle ToRectangle(this _CorsairLedPosition position)
{
//HACK DarthAffe 08.07.2018: It seems like corsair introduced a bug here - it's always 0.
- double width = position.width < 0.5 ? 10 : position.width;
- double height = position.height < 0.5 ? 10 : position.height;
- double posX = position.left;
- double posY = position.top;
+ float width = position.width < 0.5f ? 10 : (float)position.width;
+ float height = position.height < 0.5f ? 10 : (float)position.height;
+ float posX = (float)position.left;
+ float posY = (float)position.top;
return new Rectangle(posX, posY, width, height);
}
diff --git a/RGB.NET.Layout/DeviceLayout.cs b/RGB.NET.Layout/DeviceLayout.cs
index 2f34028..f4363c8 100644
--- a/RGB.NET.Layout/DeviceLayout.cs
+++ b/RGB.NET.Layout/DeviceLayout.cs
@@ -59,27 +59,27 @@ namespace RGB.NET.Layout
/// Gets or sets the width of the .
///
[XmlElement("Width")]
- public double Width { get; set; }
+ public float Width { get; set; }
///
/// Gets or sets the height of the .
///
[XmlElement("Height")]
- public double Height { get; set; }
+ public float Height { get; set; }
///
/// Gets or sets the width of one 'unit' used for the calculation of led positions and sizes.
///
[XmlElement("LedUnitWidth")]
[DefaultValue(19.0)]
- public double LedUnitWidth { get; set; } = 19.0;
+ public float LedUnitWidth { get; set; } = 19.0f;
///
/// Gets or sets the height of one 'unit' used for the calculation of led positions and sizes.
///
[XmlElement("LedUnitHeight")]
[DefaultValue(19.0)]
- public double LedUnitHeight { get; set; } = 19.0;
+ public float LedUnitHeight { get; set; } = 19.0f;
[XmlArray("Leds")]
public List InternalLeds { get; set; } = new();
diff --git a/RGB.NET.Layout/IDeviceLayout.cs b/RGB.NET.Layout/IDeviceLayout.cs
index c06d9d9..677353c 100644
--- a/RGB.NET.Layout/IDeviceLayout.cs
+++ b/RGB.NET.Layout/IDeviceLayout.cs
@@ -38,12 +38,12 @@ namespace RGB.NET.Layout
///
/// Gets or sets the width of the .
///
- double Width { get; }
+ float Width { get; }
///
/// Gets or sets the height of the .
///
- double Height { get; }
+ float Height { get; }
///
/// Gets or sets a list of representing all the of the .
diff --git a/RGB.NET.Layout/ILedLayout.cs b/RGB.NET.Layout/ILedLayout.cs
index 3747a97..5569692 100644
--- a/RGB.NET.Layout/ILedLayout.cs
+++ b/RGB.NET.Layout/ILedLayout.cs
@@ -22,22 +22,22 @@ namespace RGB.NET.Layout
///
/// Gets the x-position of the .
///
- double X { get; }
+ float X { get; }
///
/// Gets the y-position of the .
///
- double Y { get; }
+ float Y { get; }
///
/// Gets the width of the .
///
- double Width { get; }
+ float Width { get; }
///
/// Gets the height of the .
///
- double Height { get; }
+ float Height { get; }
object? CustomData { get; }
}
diff --git a/RGB.NET.Layout/LedLayout.cs b/RGB.NET.Layout/LedLayout.cs
index 3bab36c..39af645 100644
--- a/RGB.NET.Layout/LedLayout.cs
+++ b/RGB.NET.Layout/LedLayout.cs
@@ -83,25 +83,25 @@ namespace RGB.NET.Layout
/// Gets the x-position of the .
///
[XmlIgnore]
- public double X { get; private set; }
+ public float X { get; private set; }
///
/// Gets the y-position of the .
///
[XmlIgnore]
- public double Y { get; private set; }
+ public float Y { get; private set; }
///
/// Gets the width of the .
///
[XmlIgnore]
- public double Width { get; private set; }
+ public float Width { get; private set; }
///
/// Gets the height of the .
///
[XmlIgnore]
- public double Height { get; private set; }
+ public float Height { get; private set; }
#endregion
@@ -128,7 +128,7 @@ namespace RGB.NET.Layout
Y = GetLocationValue(DescriptiveY, lastLed?.Y ?? 0, Height, lastLed?.Height ?? 0);
}
- protected virtual double GetLocationValue(string value, double lastValue, double currentSize, double lastSize)
+ protected virtual float GetLocationValue(string value, float lastValue, float currentSize, float lastSize)
{
try
{
@@ -143,21 +143,21 @@ namespace RGB.NET.Layout
return lastValue + lastSize;
if (value.StartsWith("+", StringComparison.Ordinal))
- return lastValue + lastSize + double.Parse(value[1..], CultureInfo.InvariantCulture);
+ return lastValue + lastSize + float.Parse(value[1..], CultureInfo.InvariantCulture);
if (string.Equals(value, "-", StringComparison.Ordinal))
return lastValue - currentSize;
if (value.StartsWith("-", StringComparison.Ordinal))
- return lastValue - currentSize - double.Parse(value[1..], CultureInfo.InvariantCulture);
+ return lastValue - currentSize - float.Parse(value[1..], CultureInfo.InvariantCulture);
if (string.Equals(value, "~", StringComparison.Ordinal))
return (lastValue + lastSize) - currentSize;
if (value.StartsWith("~", StringComparison.Ordinal))
- return (lastValue + lastSize) - currentSize - double.Parse(value[1..], CultureInfo.InvariantCulture);
+ return (lastValue + lastSize) - currentSize - float.Parse(value[1..], CultureInfo.InvariantCulture);
- return double.Parse(value, CultureInfo.InvariantCulture);
+ return float.Parse(value, CultureInfo.InvariantCulture);
}
catch
{
@@ -165,7 +165,7 @@ namespace RGB.NET.Layout
}
}
- protected virtual double GetSizeValue(string value, double unitSize)
+ protected virtual float GetSizeValue(string value, float unitSize)
{
try
{
@@ -174,9 +174,9 @@ namespace RGB.NET.Layout
value = value.Replace(" ", string.Empty);
if (value.EndsWith("mm", StringComparison.OrdinalIgnoreCase))
- return double.Parse(value[..^2], CultureInfo.InvariantCulture);
+ return float.Parse(value[..^2], CultureInfo.InvariantCulture);
- return unitSize * double.Parse(value, CultureInfo.InvariantCulture);
+ return unitSize * float.Parse(value, CultureInfo.InvariantCulture);
}
catch
{
diff --git a/RGB.NET.Presets/Decorators/FlashDecorator.cs b/RGB.NET.Presets/Decorators/FlashDecorator.cs
index 6bb03ab..696782a 100644
--- a/RGB.NET.Presets/Decorators/FlashDecorator.cs
+++ b/RGB.NET.Presets/Decorators/FlashDecorator.cs
@@ -20,46 +20,46 @@ namespace RGB.NET.Presets.Decorators
/// Gets or sets the attack-time (in seconds) of the decorator. (default: 0.2)
/// This is close to a synthesizer envelope. (See as reference)
///
- public double Attack { get; set; } = 0.2;
+ public float Attack { get; set; } = 0.2f;
///
/// Gets or sets the decay-time (in seconds) of the decorator. (default: 0)
/// This is close to a synthesizer envelope. (See as reference)
///
- public double Decay { get; set; } = 0;
+ public float Decay { get; set; } = 0;
///
/// Gets or sets the sustain-time (in seconds) of the decorator. (default: 0.3)
/// This is close to a synthesizer envelope. (See as reference)
/// Note that this value for naming reasons represents the time NOT the level.
///
- public double Sustain { get; set; } = 0.3;
+ public float Sustain { get; set; } = 0.3f;
///
/// Gets or sets the release-time (in seconds) of the decorator. (default: 0.2)
/// This is close to a synthesizer envelope. (See as reference)
///
- public double Release { get; set; } = 0.2;
+ public float Release { get; set; } = 0.2f;
///
/// Gets or sets the level to which the oppacity (percentage) should raise in the attack-cycle. (default: 1);
///
- public double AttackValue { get; set; } = 1;
+ public float AttackValue { get; set; } = 1;
///
/// Gets or sets the level at which the oppacity (percentage) should stay in the sustain-cycle. (default: 1);
///
- public double SustainValue { get; set; } = 1;
+ public float SustainValue { get; set; } = 1;
///
/// Gets or sets the level at which the oppacity (percentage) should stay in the pause-cycle. (default: 0);
///
- public double PauseValue { get; set; } = 0;
+ public float PauseValue { get; set; } = 0;
///
/// Gets or sets the interval (in seconds) in which the decorator should repeat (if repetition is enabled). (default: 1)
///
- public double Interval { get; set; } = 1;
+ public float Interval { get; set; } = 1;
///
/// Gets or sets the amount of repetitions the decorator should do until it's finished. Zero means infinite. (default: 0)
@@ -67,10 +67,10 @@ namespace RGB.NET.Presets.Decorators
public int Repetitions { get; set; } = 0;
private ADSRPhase _currentPhase;
- private double _currentPhaseValue;
+ private float _currentPhaseValue;
private int _repetitionCount;
- private double _currentValue;
+ private float _currentValue;
#endregion
@@ -90,14 +90,14 @@ namespace RGB.NET.Presets.Decorators
///
protected override void Update(double deltaTime)
{
- _currentPhaseValue -= deltaTime;
+ _currentPhaseValue -= (float)deltaTime;
// Using ifs instead of a switch allows to skip phases with time 0.
// ReSharper disable InvertIf
if (_currentPhase == ADSRPhase.Attack)
if (_currentPhaseValue > 0)
- _currentValue = PauseValue + (Math.Min(1, (Attack - _currentPhaseValue) / Attack) * (AttackValue - PauseValue));
+ _currentValue = PauseValue + (MathF.Min(1, (Attack - _currentPhaseValue) / Attack) * (AttackValue - PauseValue));
else
{
_currentPhaseValue = Decay;
@@ -106,7 +106,7 @@ namespace RGB.NET.Presets.Decorators
if (_currentPhase == ADSRPhase.Decay)
if (_currentPhaseValue > 0)
- _currentValue = SustainValue + (Math.Min(1, _currentPhaseValue / Decay) * (AttackValue - SustainValue));
+ _currentValue = SustainValue + (MathF.Min(1, _currentPhaseValue / Decay) * (AttackValue - SustainValue));
else
{
_currentPhaseValue = Sustain;
@@ -124,7 +124,7 @@ namespace RGB.NET.Presets.Decorators
if (_currentPhase == ADSRPhase.Release)
if (_currentPhaseValue > 0)
- _currentValue = PauseValue + (Math.Min(1, _currentPhaseValue / Release) * (SustainValue - PauseValue));
+ _currentValue = PauseValue + (MathF.Min(1, _currentPhaseValue / Release) * (SustainValue - PauseValue));
else
{
_currentPhaseValue = Interval;
diff --git a/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs b/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs
index 68a0ef7..5f2280f 100644
--- a/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs
+++ b/RGB.NET.Presets/Decorators/MoveGradientDecorator.cs
@@ -26,7 +26,7 @@ namespace RGB.NET.Presets.Decorators
/// : 360 unit = 1 offset.
/// : 1 unit = 1 degree.
///
- public double Speed { get; set; }
+ public float Speed { get; set; }
// ReSharper restore MemberCanBePrivate.Global
// ReSharper restore AutoPropertyCanBeMadeGetOnly.Global
@@ -44,7 +44,7 @@ namespace RGB.NET.Presets.Decorators
/// : 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, double speed = 180.0, bool direction = true)
+ public MoveGradientDecorator(RGBSurface surface, float speed = 180.0f, bool direction = true)
: base(surface)
{
this.Speed = speed;
@@ -58,7 +58,7 @@ namespace RGB.NET.Presets.Decorators
///
protected override void Update(double deltaTime)
{
- double movement = Speed * deltaTime;
+ float movement = Speed * (float)deltaTime;
if (!Direction)
movement = -movement;
diff --git a/RGB.NET.Presets/Helper/GradientHelper.cs b/RGB.NET.Presets/Helper/GradientHelper.cs
index 32a10c3..6254fe5 100644
--- a/RGB.NET.Presets/Helper/GradientHelper.cs
+++ b/RGB.NET.Presets/Helper/GradientHelper.cs
@@ -20,7 +20,7 @@ namespace RGB.NET.Presets.Helper
/// The end of the gradient.
/// The on the gradient to which the offset is calculated.
/// The offset of the on the gradient.
- public static double CalculateLinearGradientOffset(in Point startPoint, in Point endPoint, in Point point)
+ public static float CalculateLinearGradientOffset(in Point startPoint, in Point endPoint, in Point point)
{
Point intersectingPoint;
if (startPoint.Y.EqualsInTolerance(endPoint.Y)) // Horizontal case
@@ -31,20 +31,20 @@ namespace RGB.NET.Presets.Helper
else // Diagonal case
{
- double slope = (endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
- double orthogonalSlope = -1 / slope;
+ float slope = (endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
+ float orthogonalSlope = -1 / slope;
- double startYIntercept = startPoint.Y - (slope * startPoint.X);
- double pointYIntercept = point.Y - (orthogonalSlope * point.X);
+ float startYIntercept = startPoint.Y - (slope * startPoint.X);
+ float pointYIntercept = point.Y - (orthogonalSlope * point.X);
- double intersectingPointX = (pointYIntercept - startYIntercept) / (slope - orthogonalSlope);
- double intersectingPointY = (slope * intersectingPointX) + startYIntercept;
+ float intersectingPointX = (pointYIntercept - startYIntercept) / (slope - orthogonalSlope);
+ float intersectingPointY = (slope * intersectingPointX) + startYIntercept;
intersectingPoint = new Point(intersectingPointX, intersectingPointY);
}
// Calculate distances relative to the vector start
- double intersectDistance = CalculateDistance(intersectingPoint, startPoint, endPoint);
- double gradientLength = CalculateDistance(endPoint, startPoint, endPoint);
+ float intersectDistance = CalculateDistance(intersectingPoint, startPoint, endPoint);
+ float gradientLength = CalculateDistance(endPoint, startPoint, endPoint);
return intersectDistance / gradientLength;
}
@@ -57,9 +57,9 @@ namespace RGB.NET.Presets.Helper
/// The origin of the vector.
/// The direction of the vector.
/// The signed magnitude of a on a vector.
- public static double CalculateDistance(in Point point, in Point origin, in Point direction)
+ public static float CalculateDistance(in Point point, in Point origin, in Point direction)
{
- double distance = CalculateDistance(point, origin);
+ float distance = CalculateDistance(point, origin);
return (((point.Y < origin.Y) && (direction.Y > origin.Y))
|| ((point.Y > origin.Y) && (direction.Y < origin.Y))
@@ -74,11 +74,11 @@ namespace RGB.NET.Presets.Helper
/// The first .
/// The second .
/// The distance between the two .
- public static double CalculateDistance(in Point point1, in Point point2)
+ public static float CalculateDistance(in Point point1, in Point point2)
{
- double x = point1.X - point2.X;
- double y = point1.Y - point2.Y;
- return Math.Sqrt((y * y) + (x * x));
+ float x = point1.X - point2.X;
+ float y = point1.Y - point2.Y;
+ return MathF.Sqrt((y * y) + (x * x));
}
#endregion
diff --git a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs
index 4b824a2..cf53ae4 100644
--- a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs
+++ b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs
@@ -18,23 +18,23 @@ namespace RGB.NET.Presets.Textures
{
#region Constants
- private const double PI2 = Math.PI * 2;
+ private const float PI2 = MathF.PI * 2.0f;
#endregion
#region Properties & Fields
- private double _origin = Math.Atan2(-1, 0);
+ private float _origin = MathF.Atan2(-1, 0);
///
/// Gets or sets the origin (radian-angle) this is drawn to. (default: -π/2)
///
- public double Origin
+ public float Origin
{
get => _origin;
set => SetProperty(ref _origin, value);
}
- private Point _center = new(0.5, 0.5);
+ private Point _center = new(0.5f, 0.5f);
///
/// Gets or sets the center (as percentage in the range [0..1]) of the drawn by this . (default: 0.5, 0.5)
///
@@ -86,9 +86,9 @@ namespace RGB.NET.Presets.Textures
protected override Color GetColor(in Point point)
{
- double angle = Math.Atan2(point.Y - Center.Y, point.X - Center.X) - Origin;
+ float angle = MathF.Atan2(point.Y - Center.Y, point.X - Center.X) - Origin;
if (angle < 0) angle += PI2;
- double offset = angle / PI2;
+ float offset = angle / PI2;
return Gradient.GetColor(offset);
}
diff --git a/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs b/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs
index 5271754..e52788c 100644
--- a/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs
+++ b/RGB.NET.Presets/Textures/Gradients/AbstractGradient.cs
@@ -96,23 +96,23 @@ namespace RGB.NET.Presets.Textures.Gradients
///
///
///
- 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;
}
///
- public abstract Color GetColor(double offset);
+ public abstract Color GetColor(float offset);
///
- 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;
diff --git a/RGB.NET.Presets/Textures/Gradients/GradientStop.cs b/RGB.NET.Presets/Textures/Gradients/GradientStop.cs
index 7626bcb..aba665d 100644
--- a/RGB.NET.Presets/Textures/Gradients/GradientStop.cs
+++ b/RGB.NET.Presets/Textures/Gradients/GradientStop.cs
@@ -12,11 +12,11 @@ namespace RGB.NET.Presets.Textures.Gradients
{
#region Properties & Fields
- private double _offset;
+ private float _offset;
///
/// Gets or sets the percentage offset to place this . This should be inside the range of [0..1] but it's not necessary.
///
- public double Offset
+ public float Offset
{
get => _offset;
set => SetProperty(ref _offset, value);
@@ -41,7 +41,7 @@ namespace RGB.NET.Presets.Textures.Gradients
///
/// The percentage offset to place this .
/// The of the .
- public GradientStop(double offset, Color color)
+ public GradientStop(float offset, Color color)
{
this.Offset = offset;
this.Color = color;
diff --git a/RGB.NET.Presets/Textures/Gradients/IGradient.cs b/RGB.NET.Presets/Textures/Gradients/IGradient.cs
index 58824da..1917256 100644
--- a/RGB.NET.Presets/Textures/Gradients/IGradient.cs
+++ b/RGB.NET.Presets/Textures/Gradients/IGradient.cs
@@ -19,12 +19,12 @@ namespace RGB.NET.Presets.Textures.Gradients
///
/// The percentage offset to take the from.
/// The at the specific offset.
- Color GetColor(double offset);
+ Color GetColor(float offset);
///
/// Moves the by the provided offset.
///
/// The offset the should be moved.
- void Move(double offset);
+ void Move(float offset);
}
}
diff --git a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs
index 716f579..2aa898e 100644
--- a/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs
+++ b/RGB.NET.Presets/Textures/Gradients/LinearGradient.cs
@@ -83,7 +83,7 @@ namespace RGB.NET.Presets.Textures.Gradients
///
/// The percentage offset to take the color from.
/// The at the specific offset.
- 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
/// The ordered list of to choose from.
/// Bool indicating if the gradient should be wrapped or not.
///
- protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(double offset, LinkedList orderedStops, bool wrap)
+ protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(float offset, LinkedList orderedStops, bool wrap)
{
LinkedList gradientStops = new(orderedStops);
diff --git a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs
index 90c867e..1ec32e2 100644
--- a/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs
+++ b/RGB.NET.Presets/Textures/Gradients/RainbowGradient.cs
@@ -17,21 +17,21 @@ namespace RGB.NET.Presets.Textures.Gradients
{
#region Properties & Fields
- private double _startHue;
+ private float _startHue;
///
/// Gets or sets the hue (in degrees) to start from.
///
- public double StartHue
+ public float StartHue
{
get => _startHue;
set => SetProperty(ref _startHue, value);
}
- private double _endHue;
+ private float _endHue;
///
/// Gets or sets the hue (in degrees) to end the with.
///
- public double EndHue
+ public float EndHue
{
get => _endHue;
set => SetProperty(ref _endHue, value);
@@ -53,7 +53,7 @@ namespace RGB.NET.Presets.Textures.Gradients
///
/// The hue (in degrees) to start from (default: 0)
/// The hue (in degrees) to end with (default: 360)
- 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
///
/// The percentage offset to take the color from.
/// The color at the specific offset.
- 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);
}
///
- public void Move(double offset)
+ public void Move(float offset)
{
// RainbowGradient is calculated inverse
offset *= -1;
diff --git a/RGB.NET.Presets/Textures/LinearGradientTexture.cs b/RGB.NET.Presets/Textures/LinearGradientTexture.cs
index ae82546..d37bf6a 100644
--- a/RGB.NET.Presets/Textures/LinearGradientTexture.cs
+++ b/RGB.NET.Presets/Textures/LinearGradientTexture.cs
@@ -19,7 +19,7 @@ namespace RGB.NET.Presets.Textures
{
#region Properties & Fields
- private Point _startPoint = new(0, 0.5);
+ 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)
///
@@ -29,7 +29,7 @@ namespace RGB.NET.Presets.Textures
set => SetProperty(ref _startPoint, value);
}
- private Point _endPoint = new(1, 0.5);
+ 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)
///
@@ -70,7 +70,7 @@ namespace RGB.NET.Presets.Textures
protected override Color GetColor(in Point point)
{
- double offset = GradientHelper.CalculateLinearGradientOffset(StartPoint, EndPoint, point);
+ float offset = GradientHelper.CalculateLinearGradientOffset(StartPoint, EndPoint, point);
return Gradient.GetColor(offset);
}
diff --git a/RGB.NET.Presets/Textures/RadialGradientTexture.cs b/RGB.NET.Presets/Textures/RadialGradientTexture.cs
index 0e335a9..b5ff848 100644
--- a/RGB.NET.Presets/Textures/RadialGradientTexture.cs
+++ b/RGB.NET.Presets/Textures/RadialGradientTexture.cs
@@ -16,9 +16,9 @@ namespace RGB.NET.Presets.Textures
{
#region Properties & Fields
- private double _referenceDistance = GradientHelper.CalculateDistance(new Point(0.5, 0.5), new Point(0, 0));
+ private float _referenceDistance = GradientHelper.CalculateDistance(new Point(0.5f, 0.5f), new Point(0, 0));
- private Point _center = new(0.5, 0.5);
+ private Point _center = new(0.5f, 0.5f);
///
/// Gets or sets the center (as percentage in the range [0..1]) around which the should be drawn. (default: 0.5, 0.5)
///
@@ -61,15 +61,15 @@ namespace RGB.NET.Presets.Textures
private void CalculateReferenceDistance()
{
- double referenceX = Center.X < 0.5 ? 1 : 0;
- double referenceY = Center.Y < 0.5 ? 1 : 0;
+ float referenceX = Center.X < 0.5f ? 1 : 0;
+ float referenceY = Center.Y < 0.5f ? 1 : 0;
_referenceDistance = GradientHelper.CalculateDistance(new Point(referenceX, referenceY), Center);
}
protected override Color GetColor(in Point point)
{
- double distance = GradientHelper.CalculateDistance(point, Center);
- double offset = distance / _referenceDistance;
+ float distance = GradientHelper.CalculateDistance(point, Center);
+ float offset = distance / _referenceDistance;
return Gradient.GetColor(offset);
}
diff --git a/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs b/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs
index bd0fda1..67b5b77 100644
--- a/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs
+++ b/Tests/RGB.NET.Core.Tests/Color/ColorTest.cs
@@ -221,36 +221,36 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void RGBPercentConstructorTest()
{
- Core.Color color = new(0.25341, 0.55367, 1);
+ Core.Color color = new(0.25341f, 0.55367f, 1);
- Assert.AreEqual(1, color.A, DoubleExtensions.TOLERANCE, "A is not 1");
- Assert.AreEqual(0.25341, color.R, DoubleExtensions.TOLERANCE, "R is not 0.25341");
- Assert.AreEqual(0.55367, color.G, DoubleExtensions.TOLERANCE, "G is not 0.55367");
- Assert.AreEqual(1, color.B, DoubleExtensions.TOLERANCE, "B is not 1");
+ Assert.AreEqual(1, color.A, FloatExtensions.TOLERANCE, "A is not 1");
+ Assert.AreEqual(0.25341, color.R, FloatExtensions.TOLERANCE, "R is not 0.25341");
+ Assert.AreEqual(0.55367, color.G, FloatExtensions.TOLERANCE, "G is not 0.55367");
+ Assert.AreEqual(1, color.B, FloatExtensions.TOLERANCE, "B is not 1");
}
[TestMethod]
public void ARGBPercentConstructorTest()
{
- Core.Color color = new(0.3315, 0.25341, 0.55367, 1);
+ Core.Color color = new(0.3315f, 0.25341f, 0.55367f, 1);
- Assert.AreEqual(0.3315, color.A, DoubleExtensions.TOLERANCE, "A is not 0.3315");
- Assert.AreEqual(0.25341, color.R, DoubleExtensions.TOLERANCE, "R is not 0.25341");
- Assert.AreEqual(0.55367, color.G, DoubleExtensions.TOLERANCE, "G is not 0.55367");
- Assert.AreEqual(1, color.B, DoubleExtensions.TOLERANCE, "B is not 1");
+ Assert.AreEqual(0.3315f, color.A, FloatExtensions.TOLERANCE, "A is not 0.3315");
+ Assert.AreEqual(0.25341f, color.R, FloatExtensions.TOLERANCE, "R is not 0.25341");
+ Assert.AreEqual(0.55367f, color.G, FloatExtensions.TOLERANCE, "G is not 0.55367");
+ Assert.AreEqual(1, color.B, FloatExtensions.TOLERANCE, "B is not 1");
}
[TestMethod]
public void RGBPercentConstructorClampTest()
{
- Core.Color color1 = new(1.1, 1.1, 1.1);
+ Core.Color color1 = new(1.1f, 1.1f, 1.1f);
Assert.AreEqual(1, color1.A, "A is not 1");
Assert.AreEqual(1, color1.R, "R is not 1");
Assert.AreEqual(1, color1.G, "G is not 1");
Assert.AreEqual(1, color1.B, "B is not 1");
- Core.Color color2 = new(-1.0, -1.0, -1.0);
+ Core.Color color2 = new(-1.0f, -1.0f, -1.0f);
Assert.AreEqual(1, color2.A, "A is not 1");
Assert.AreEqual(0, color2.R, "R is not 0");
@@ -261,14 +261,14 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void ARGBPercentConstructorClampTest()
{
- Core.Color color1 = new(1.1, 1.1, 1.1, 1.1);
+ Core.Color color1 = new(1.1f, 1.1f, 1.1f, 1.1f);
Assert.AreEqual(1, color1.A, "A is not 1");
Assert.AreEqual(1, color1.R, "R is not 1");
Assert.AreEqual(1, color1.G, "G is not 1");
Assert.AreEqual(1, color1.B, "B is not 1");
- Core.Color color2 = new(-1.0, -1.0, -1.0, -1.0);
+ Core.Color color2 = new(-1.0f, -1.0f, -1.0f, -1.0f);
Assert.AreEqual(0, color2.A, "A is not 0");
Assert.AreEqual(0, color2.R, "R is not 0");
diff --git a/Tests/RGB.NET.Core.Tests/Color/HSVColorTest.cs b/Tests/RGB.NET.Core.Tests/Color/HSVColorTest.cs
index 823a203..7d365c5 100644
--- a/Tests/RGB.NET.Core.Tests/Color/HSVColorTest.cs
+++ b/Tests/RGB.NET.Core.Tests/Color/HSVColorTest.cs
@@ -12,55 +12,55 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddHueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.AddHSV(hue: 30);
- Assert.AreEqual(HSVColor.Create(210, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(210, 0.5f, 0.5f), result);
}
[TestMethod]
public void AddHueWrapTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.AddHSV(hue: 220);
- Assert.AreEqual(HSVColor.Create(40, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(40, 0.5f, 0.5f), result);
}
[TestMethod]
public void AddSaturationTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.AddHSV(saturation: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddHSV(saturation: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.8, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.8f, 0.5f), result);
}
[TestMethod]
public void AddSaturationClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.AddHSV(saturation: 0.8);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddHSV(saturation: 0.8f);
- Assert.AreEqual(HSVColor.Create(180, 1.0, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 1.0f, 0.5f), result);
}
[TestMethod]
public void AddValueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.AddHSV(value: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddHSV(value: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 0.8), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 0.8f), result);
}
[TestMethod]
public void AddValueClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.AddHSV(value: 0.8);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddHSV(value: 0.8f);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 1.0), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 1.0f), result);
}
#endregion
@@ -70,55 +70,55 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractHueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SubtractHSV(hue: 30);
- Assert.AreEqual(HSVColor.Create(150, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(150, 0.5f, 0.5f), result);
}
[TestMethod]
public void SubtractHueWrapTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SubtractHSV(hue: 220);
- Assert.AreEqual(HSVColor.Create(320, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(320, 0.5f, 0.5f), result);
}
[TestMethod]
public void SubtractSaturationTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SubtractHSV(saturation: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractHSV(saturation: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.2, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.2f, 0.5f), result);
}
[TestMethod]
public void SubtractSaturationClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SubtractHSV(saturation: 0.8);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractHSV(saturation: 0.8f);
- Assert.AreEqual(HSVColor.Create(180, 0, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 0, 0.5f), result);
}
[TestMethod]
public void SubtractValueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SubtractHSV(value: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractHSV(value: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 0.2), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 0.2f), result);
}
[TestMethod]
public void SubtractValueClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SubtractHSV(value: .8);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractHSV(value: 0.8f);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 0), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 0), result);
}
#endregion
@@ -128,55 +128,55 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void MultiplyHueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.MultiplyHSV(hue: 1.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.MultiplyHSV(hue: 1.5f);
- Assert.AreEqual(HSVColor.Create(270, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(270, 0.5f, 0.5f), result);
}
[TestMethod]
public void MultiplyHueWrapTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.MultiplyHSV(hue: 3);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 0.5f), result);
}
[TestMethod]
public void MultiplySaturationTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.2, 0.2);
+ Core.Color baseColor = HSVColor.Create(180, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyHSV(saturation: 3);
- Assert.AreEqual(HSVColor.Create(180, 0.6, 0.2), result);
+ Assert.AreEqual(HSVColor.Create(180,0.6f, 0.2f), result);
}
[TestMethod]
public void MultiplySaturationClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.MultiplyHSV(saturation: 3);
- Assert.AreEqual(HSVColor.Create(180, 1.0, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 1.0f, 0.5f), result);
}
[TestMethod]
public void MultiplyValueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.2, 0.2);
+ Core.Color baseColor = HSVColor.Create(180, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyHSV(value: 3);
- Assert.AreEqual(HSVColor.Create(180, 0.2, 0.6), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.2f,0.6f), result);
}
[TestMethod]
public void MultiplyValueClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.MultiplyHSV(value: 3);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 1.0), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 1.0f), result);
}
#endregion
@@ -186,28 +186,28 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void DivideHueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.DivideHSV(hue: 30);
- Assert.AreEqual(HSVColor.Create(6, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(6, 0.5f, 0.5f), result);
}
[TestMethod]
public void DivideSaturationTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.6, 0.6);
+ Core.Color baseColor = HSVColor.Create(180,0.6f,0.6f);
Core.Color result = baseColor.DivideHSV(saturation: 2);
- Assert.AreEqual(HSVColor.Create(180, 0.3, 0.6), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.3f,0.6f), result);
}
[TestMethod]
public void DivideValueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.6, 0.6);
+ Core.Color baseColor = HSVColor.Create(180,0.6f,0.6f);
Core.Color result = baseColor.DivideHSV(value: 2);
- Assert.AreEqual(HSVColor.Create(180, 0.6, 0.3), result);
+ Assert.AreEqual(HSVColor.Create(180,0.6f, 0.3f), result);
}
#endregion
@@ -217,64 +217,64 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetHueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SetHSV(hue: 30);
- Assert.AreEqual(HSVColor.Create(30, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(30, 0.5f, 0.5f), result);
}
[TestMethod]
public void SetHueWrapTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SetHSV(hue: 440);
- Assert.AreEqual(HSVColor.Create(80, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(80, 0.5f, 0.5f), result);
}
[TestMethod]
public void SetHueWrapNegativeTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SetHSV(hue: -30);
- Assert.AreEqual(HSVColor.Create(330, 0.5, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(330, 0.5f, 0.5f), result);
}
[TestMethod]
public void SetSaturationTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SetHSV(saturation: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetHSV(saturation: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.3, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.3f, 0.5f), result);
}
[TestMethod]
public void SetSaturationClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SetHSV(saturation: 2);
- Assert.AreEqual(HSVColor.Create(180, 1.0, 0.5), result);
+ Assert.AreEqual(HSVColor.Create(180, 1.0f, 0.5f), result);
}
[TestMethod]
public void SetValueTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
- Core.Color result = baseColor.SetHSV(value: 0.3);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetHSV(value: 0.3f);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 0.3), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 0.3f), result);
}
[TestMethod]
public void SetValueClampTest()
{
- Core.Color baseColor = HSVColor.Create(180, 0.5, 0.5);
+ Core.Color baseColor = HSVColor.Create(180, 0.5f, 0.5f);
Core.Color result = baseColor.SetHSV(value: 2);
- Assert.AreEqual(HSVColor.Create(180, 0.5, 1.0), result);
+ Assert.AreEqual(HSVColor.Create(180, 0.5f, 1.0f), result);
}
#endregion
diff --git a/Tests/RGB.NET.Core.Tests/Color/RGBColorTest.cs b/Tests/RGB.NET.Core.Tests/Color/RGBColorTest.cs
index 7a9abc9..ea5a1cc 100644
--- a/Tests/RGB.NET.Core.Tests/Color/RGBColorTest.cs
+++ b/Tests/RGB.NET.Core.Tests/Color/RGBColorTest.cs
@@ -30,19 +30,19 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void BlendUpTest()
{
- Core.Color baseColor = new(0.0, 0.0, 0.0);
- Core.Color blendColor = new(0.5, 1.0, 1.0, 1.0);
+ Core.Color baseColor = new(0.0f, 0.0f, 0.0f);
+ Core.Color blendColor = new(0.5f, 1.0f, 1.0f, 1.0f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.5), baseColor.Blend(blendColor));
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.5f), baseColor.Blend(blendColor));
}
[TestMethod]
public void BlendDownTest()
{
- Core.Color baseColor = new(1.0, 1.0, 1.0);
- Core.Color blendColor = new(0.5, 0.0, 0.0, 0.0);
+ Core.Color baseColor = new(1.0f, 1.0f, 1.0f);
+ Core.Color blendColor = new(0.5f, 0.0f, 0.0f, 0.0f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.5), baseColor.Blend(blendColor));
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.5f), baseColor.Blend(blendColor));
}
#endregion
@@ -61,10 +61,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddRGBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.AddRGB(0.2, 0.3, 0.4);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddRGB(0.2f, 0.3f, 0.4f);
- Assert.AreEqual(new Core.Color(0.5, 0.7, 0.8, 0.9), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.7f, 0.8f, 0.9f), result);
}
[TestMethod]
@@ -79,10 +79,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddAPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.AddA(0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddA(0.1f);
- Assert.AreEqual(new Core.Color(0.6, 0.5, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.6f, 0.5f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -97,10 +97,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddRPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.AddRGB(r: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddRGB(r: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.6, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.6f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -115,10 +115,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddGPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.AddRGB(g: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddRGB(g: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.6, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.6f, 0.5f), result);
}
[TestMethod]
@@ -133,10 +133,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void AddBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.AddRGB(b: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.AddRGB(b: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.5, 0.6), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.5f, 0.6f), result);
}
#endregion
@@ -155,10 +155,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractRGBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SubtractRGB(0.2, 0.3, 0.4);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractRGB(0.2f, 0.3f, 0.4f);
- Assert.AreEqual(new Core.Color(0.5, 0.3, 0.2, 0.1), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.3f, 0.2f, 0.1f), result);
}
[TestMethod]
@@ -173,10 +173,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractAPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SubtractA(0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractA(0.1f);
- Assert.AreEqual(new Core.Color(0.4, 0.5, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.4f, 0.5f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -191,10 +191,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractRPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SubtractRGB(r: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractRGB(r: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.4, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.4f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -209,10 +209,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractGPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SubtractRGB(g: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractRGB(g: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.4, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.4f, 0.5f), result);
}
[TestMethod]
@@ -227,10 +227,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SubtractBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SubtractRGB(b: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SubtractRGB(b: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.5, 0.4), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.5f, 0.4f), result);
}
#endregion
@@ -240,46 +240,46 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void MultiplyRGBPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyRGB(3, 4, 5);
- Assert.AreEqual(new Core.Color(0.2, 0.6, 0.8, 1.0), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.6f, 0.8f, 1.0f), result);
}
[TestMethod]
public void MultiplyAPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyA(3);
- Assert.AreEqual(new Core.Color(0.6, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.6f, 0.2f, 0.2f, 0.2f), result);
}
[TestMethod]
public void MultiplyRPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyRGB(r: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.6, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.6f, 0.2f, 0.2f), result);
}
[TestMethod]
public void MultiplyGPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyRGB(g: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.6, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.6f, 0.2f), result);
}
[TestMethod]
public void MultiplyBPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.MultiplyRGB(b: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.6), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.6f), result);
}
#endregion
@@ -289,46 +289,46 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void DivideRGBPercentTest()
{
- Core.Color baseColor = new(0.2, 0.6, 0.8, 1.0);
+ Core.Color baseColor = new(0.2f, 0.6f, 0.8f, 1.0f);
Core.Color result = baseColor.DivideRGB(3, 4, 5);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.2f), result);
}
[TestMethod]
public void DivideAPercentTest()
{
- Core.Color baseColor = new(0.6, 0.2, 0.2, 0.2);
+ Core.Color baseColor = new(0.6f, 0.2f, 0.2f, 0.2f);
Core.Color result = baseColor.DivideA(3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.2f), result);
}
[TestMethod]
public void DivideRPercentTest()
{
- Core.Color baseColor = new(0.2, 0.6, 0.2, 0.2);
+ Core.Color baseColor = new(0.2f, 0.6f, 0.2f, 0.2f);
Core.Color result = baseColor.DivideRGB(r: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.2f), result);
}
[TestMethod]
public void DivideGPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.6, 0.2);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.6f, 0.2f);
Core.Color result = baseColor.DivideRGB(g: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.2f), result);
}
[TestMethod]
public void DivideBPercentTest()
{
- Core.Color baseColor = new(0.2, 0.2, 0.2, 0.6);
+ Core.Color baseColor = new(0.2f, 0.2f, 0.2f, 0.6f);
Core.Color result = baseColor.DivideRGB(b: 3);
- Assert.AreEqual(new Core.Color(0.2, 0.2, 0.2, 0.2), result);
+ Assert.AreEqual(new Core.Color(0.2f, 0.2f, 0.2f, 0.2f), result);
}
#endregion
@@ -347,10 +347,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetRGBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SetRGB(0.2, 0.3, 0.4);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetRGB(0.2f, 0.3f, 0.4f);
- Assert.AreEqual(new Core.Color(0.5, 0.2, 0.3, 0.4), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.2f, 0.3f, 0.4f), result);
}
[TestMethod]
@@ -365,10 +365,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetAPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SetA(0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetA(0.1f);
- Assert.AreEqual(new Core.Color(0.1, 0.5, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.1f, 0.5f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -383,10 +383,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetRPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SetRGB(r: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetRGB(r: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.1, 0.5, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.1f, 0.5f, 0.5f), result);
}
[TestMethod]
@@ -401,10 +401,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetGPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SetRGB(g: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetRGB(g: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.1, 0.5), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.1f, 0.5f), result);
}
[TestMethod]
@@ -419,10 +419,10 @@ namespace RGB.NET.Core.Tests.Color
[TestMethod]
public void SetBPercentTest()
{
- Core.Color baseColor = new(0.5, 0.5, 0.5, 0.5);
- Core.Color result = baseColor.SetRGB(b: 0.1);
+ Core.Color baseColor = new(0.5f, 0.5f, 0.5f, 0.5f);
+ Core.Color result = baseColor.SetRGB(b: 0.1f);
- Assert.AreEqual(new Core.Color(0.5, 0.5, 0.5, 0.1), result);
+ Assert.AreEqual(new Core.Color(0.5f, 0.5f, 0.5f, 0.1f), result);
}
#endregion