diff --git a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs index c1859c2f..36f41c8c 100644 --- a/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/DefaultColorBehavior.cs @@ -14,7 +14,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// Converts the individual byte values of this to a human-readable string. /// /// A string that contains the individual byte values of this . For example "[A: 255, R: 255, G: 0, B: 0]". - public string ToString(in Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; + public string ToString(Color color) => $"[A: {color.GetA()}, R: {color.GetR()}, G: {color.GetG()}, B: {color.GetB()}]"; /// /// Tests whether the specified object is a and is equivalent to this . @@ -22,7 +22,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - public bool Equals(in Color color, object? obj) => obj is Color color2 && Equals(color, color2); + public bool Equals(Color color, object? obj) => obj is Color color2 && Equals(color, color2); /// /// Tests whether the specified object is a and is equivalent to this . @@ -30,7 +30,7 @@ public sealed class DefaultColorBehavior : IColorBehavior /// The first color to test. /// The second color to test. /// true if equivalent to this ; otherwise, false. - public bool Equals(in Color color, in Color color2) => color.A.EqualsInTolerance(color2.A) + public bool Equals(Color color, Color color2) => color.A.EqualsInTolerance(color2.A) && color.R.EqualsInTolerance(color2.R) && color.G.EqualsInTolerance(color2.G) && color.B.EqualsInTolerance(color2.B); @@ -39,14 +39,14 @@ public bool Equals(in Color color, in Color color2) => color.A.EqualsInTolerance /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - public int GetHashCode(in Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); + public int GetHashCode(Color color) => HashCode.Combine(color.A, color.R, color.G, color.B); /// /// Blends a over this color. /// /// The to to blend over. /// The to blend. - public Color Blend(in Color baseColor, in Color blendColor) + public Color Blend(Color baseColor, Color blendColor) { if (blendColor.A.EqualsInTolerance(0)) return baseColor; diff --git a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs index f365f37e..432bb4f0 100644 --- a/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs +++ b/RGB.NET.Core/Color/Behaviors/IColorBehavior.cs @@ -10,7 +10,7 @@ public interface IColorBehavior /// /// The color to convert. /// The string representation of the specified color. - string ToString(in Color color); + string ToString(Color color); /// /// Tests whether the specified object is a and is equivalent to this . @@ -18,7 +18,7 @@ public interface IColorBehavior /// The color to test. /// The object to test. /// true if is a equivalent to this ; otherwise, false. - bool Equals(in Color color, object? obj); + bool Equals(Color color, object? obj); /// /// Tests whether the specified object is a and is equivalent to this . @@ -26,18 +26,18 @@ public interface IColorBehavior /// The first color to test. /// The second color to test. /// true if equivalent to this ; otherwise, false. - bool Equals(in Color color, in Color color2); + bool Equals(Color color, Color color2); /// /// Returns a hash code for this . /// /// An integer value that specifies the hash code for this . - int GetHashCode(in Color color); + int GetHashCode(Color color); /// /// Blends a over this color. /// /// The to to blend over. /// The to blend. - Color Blend(in Color baseColor, in Color blendColor); + Color Blend(Color baseColor, Color blendColor); } \ No newline at end of file diff --git a/RGB.NET.Core/Color/Color.cs b/RGB.NET.Core/Color/Color.cs index c7865026..3ef16fb9 100644 --- a/RGB.NET.Core/Color/Color.cs +++ b/RGB.NET.Core/Color/Color.cs @@ -175,7 +175,7 @@ public Color(float a, float r, float g, float b) /// Initializes a new instance of the struct by cloning a existing . /// /// The the values are copied from. - public Color(in Color color) + public Color(Color color) : this(color.A, color.R, color.G, color.B) { } @@ -214,7 +214,7 @@ public Color(in Color color) /// Blends a over this color, as defined by the current . /// /// The to blend. - public Color Blend(in Color color) => Behavior.Blend(this, color); + public Color Blend(Color color) => Behavior.Blend(this, color); #endregion @@ -226,7 +226,7 @@ public Color(in Color color) /// The base color. /// The color to blend. /// The blended color. - public static Color operator +(in Color color1, in Color color2) => color1.Blend(color2); + public static Color operator +(Color color1, Color color2) => color1.Blend(color2); /// /// Returns a value that indicates whether two specified are equal. @@ -234,7 +234,7 @@ public Color(in Color color) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Color color1, in Color color2) => color1.Equals(color2); + public static bool operator ==(Color color1, Color color2) => color1.Equals(color2); /// /// Returns a value that indicates whether two specified are equal. @@ -242,7 +242,7 @@ public Color(in Color color) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Color color1, in Color color2) => !(color1 == color2); + public static bool operator !=(Color color1, Color color2) => !(color1 == color2); /// /// Converts a of ARGB-components to a . diff --git a/RGB.NET.Core/Color/HSVColor.cs b/RGB.NET.Core/Color/HSVColor.cs index 35af63fe..c4177db6 100644 --- a/RGB.NET.Core/Color/HSVColor.cs +++ b/RGB.NET.Core/Color/HSVColor.cs @@ -16,21 +16,21 @@ public static class HSVColor /// /// The color to get the value from. /// The hue component value of the color. - public static float GetHue(this in 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]. /// /// The color to get the value from. /// The saturation component value of the color. - public static float GetSaturation(this in 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]. /// /// The color to get the value from. /// The value component value of the color. - public static float GetValue(this in 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 . @@ -40,7 +40,7 @@ public static class HSVColor /// /// The color to get the value from. /// A tuple containing the hue, saturation and value component value of the color. - public static (float hue, float saturation, float value) GetHSV(this in Color color) + public static (float hue, float saturation, float value) GetHSV(this Color color) => CaclulateHSVFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float hue, float saturation, float value) GetHSV(this in Color co /// The saturation value to add. /// The value value to add. /// The new color after the modification. - public static Color AddHSV(this in Color color, float hue = 0, float saturation = 0, float value = 0) + public static Color AddHSV(this Color color, float hue = 0, float saturation = 0, float value = 0) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue + hue, cSaturation + saturation, cValue + value); @@ -69,7 +69,7 @@ public static Color AddHSV(this in Color color, float hue = 0, float saturation /// The saturation value to subtract. /// The value value to subtract. /// The new color after the modification. - public static Color SubtractHSV(this in Color color, float hue = 0, float saturation = 0, float value = 0) + public static Color SubtractHSV(this Color color, float hue = 0, float saturation = 0, float value = 0) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue - hue, cSaturation - saturation, cValue - value); @@ -83,7 +83,7 @@ public static Color SubtractHSV(this in Color color, float hue = 0, float satura /// The saturation value to multiply. /// The value value to multiply. /// The new color after the modification. - public static Color MultiplyHSV(this in Color color, float hue = 1, float saturation = 1, float value = 1) + public static Color MultiplyHSV(this Color color, float hue = 1, float saturation = 1, float value = 1) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue * hue, cSaturation * saturation, cValue * value); @@ -97,7 +97,7 @@ public static Color MultiplyHSV(this in Color color, float hue = 1, float satura /// The saturation value to divide. /// The value value to divide. /// The new color after the modification. - public static Color DivideHSV(this in Color color, float hue = 1, float saturation = 1, float value = 1) + public static Color DivideHSV(this Color color, float hue = 1, float saturation = 1, float value = 1) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, cHue / hue, cSaturation / saturation, cValue / value); @@ -111,7 +111,7 @@ public static Color DivideHSV(this in Color color, float hue = 1, float saturati /// The saturation value to set. /// The value value to set. /// The new color after the modification. - public static Color SetHSV(this in Color color, float? hue = null, float? saturation = null, float? value = null) + public static Color SetHSV(this Color color, float? hue = null, float? saturation = null, float? value = null) { (float cHue, float cSaturation, float cValue) = color.GetHSV(); return Create(color.A, hue ?? cHue, saturation ?? cSaturation, value ?? cValue); diff --git a/RGB.NET.Core/Color/HclColor.cs b/RGB.NET.Core/Color/HclColor.cs index 4133c582..7a6e5be7 100644 --- a/RGB.NET.Core/Color/HclColor.cs +++ b/RGB.NET.Core/Color/HclColor.cs @@ -16,21 +16,21 @@ public static class HclColor /// /// The color to get the value from. /// The H component value of the color. - public static float GetHclH(this in Color color) => color.GetHcl().h; + public static float GetHclH(this Color color) => color.GetHcl().h; /// /// Gets the c component value (Hcl-color space) of this in the range [0..1]. /// /// The color to get the value from. /// The c component value of the color. - public static float GetHclC(this in Color color) => color.GetHcl().c; + public static float GetHclC(this Color color) => color.GetHcl().c; /// /// Gets the l component value (Hcl-color space) of this in the range [0..1]. /// /// The color to get the value from. /// The l component value of the color. - public static float GetHclL(this in Color color) => color.GetHcl().l; + public static float GetHclL(this Color color) => color.GetHcl().l; /// /// Gets the H, c and l component values (Hcl-color space) of this . @@ -40,7 +40,7 @@ public static class HclColor /// /// The color to get the value from. /// A tuple containing the H, c and l component value of the color. - public static (float h, float c, float l) GetHcl(this in Color color) + public static (float h, float c, float l) GetHcl(this Color color) => CalculateHclFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float h, float c, float l) GetHcl(this in Color color) /// The c value to add. /// The l value to add. /// The new color after the modification. - public static Color AddHcl(this in Color color, float h = 0, float c = 0, float l = 0) + public static Color AddHcl(this Color color, float h = 0, float c = 0, float l = 0) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH + h, cC + c, cL + l); @@ -69,7 +69,7 @@ public static Color AddHcl(this in Color color, float h = 0, float c = 0, float /// The c value to subtract. /// The l value to subtract. /// The new color after the modification. - public static Color SubtractHcl(this in Color color, float h = 0, float c = 0, float l = 0) + public static Color SubtractHcl(this Color color, float h = 0, float c = 0, float l = 0) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH - h, cC - c, cL - l); @@ -83,7 +83,7 @@ public static Color SubtractHcl(this in Color color, float h = 0, float c = 0, f /// The c value to multiply. /// The l value to multiply. /// The new color after the modification. - public static Color MultiplyHcl(this in Color color, float h = 1, float c = 1, float l = 1) + public static Color MultiplyHcl(this Color color, float h = 1, float c = 1, float l = 1) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH * h, cC * c, cL * l); @@ -97,7 +97,7 @@ public static Color MultiplyHcl(this in Color color, float h = 1, float c = 1, f /// The c value to divide. /// The l value to divide. /// The new color after the modification. - public static Color DivideHcl(this in Color color, float h = 1, float c = 1, float l = 1) + public static Color DivideHcl(this Color color, float h = 1, float c = 1, float l = 1) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, cH / h, cC / c, cL / l); @@ -111,7 +111,7 @@ public static Color DivideHcl(this in Color color, float h = 1, float c = 1, flo /// The c value to set. /// The l value to set. /// The new color after the modification. - public static Color SetHcl(this in Color color, float? h = null, float? c = null, float? l = null) + public static Color SetHcl(this Color color, float? h = null, float? c = null, float? l = null) { (float cH, float cC, float cL) = color.GetHcl(); return Create(color.A, h ?? cH, c ?? cC, l ?? cL); diff --git a/RGB.NET.Core/Color/LabColor.cs b/RGB.NET.Core/Color/LabColor.cs index 7be06502..438f0692 100644 --- a/RGB.NET.Core/Color/LabColor.cs +++ b/RGB.NET.Core/Color/LabColor.cs @@ -16,21 +16,21 @@ public static class LabColor /// /// The color to get the value from. /// The L component value of the color. - public static float GetLabL(this in Color color) => color.GetLab().l; + public static float GetLabL(this Color color) => color.GetLab().l; /// /// Gets the a component value (Lab-color space) of this in the range [0..1]. /// /// The color to get the value from. /// The a component value of the color. - public static float GetLabA(this in Color color) => color.GetLab().a; + public static float GetLabA(this Color color) => color.GetLab().a; /// /// Gets the b component value (Lab-color space) of this in the range [0..1]. /// /// The color to get the value from. /// The b component value of the color. - public static float GetLabB(this in Color color) => color.GetLab().b; + public static float GetLabB(this Color color) => color.GetLab().b; /// /// Gets the L, a and b component values (Lab-color space) of this . @@ -40,7 +40,7 @@ public static class LabColor /// /// The color to get the value from. /// A tuple containing the L, a and b component value of the color. - public static (float l, float a, float b) GetLab(this in Color color) + public static (float l, float a, float b) GetLab(this Color color) => CalculateLabFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float l, float a, float b) GetLab(this in Color color) /// The a value to add. /// The b value to add. /// The new color after the modification. - public static Color AddLab(this in Color color, float l = 0, float a = 0, float b = 0) + public static Color AddLab(this Color color, float l = 0, float a = 0, float b = 0) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL + l, cA + a, cB + b); @@ -69,7 +69,7 @@ public static Color AddLab(this in Color color, float l = 0, float a = 0, float /// The a value to subtract. /// The b value to subtract. /// The new color after the modification. - public static Color SubtractLab(this in Color color, float l = 0, float a = 0, float b = 0) + public static Color SubtractLab(this Color color, float l = 0, float a = 0, float b = 0) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL - l, cA - a, cB - b); @@ -83,7 +83,7 @@ public static Color SubtractLab(this in Color color, float l = 0, float a = 0, f /// The a value to multiply. /// The b value to multiply. /// The new color after the modification. - public static Color MultiplyLab(this in Color color, float l = 1, float a = 1, float b = 1) + public static Color MultiplyLab(this Color color, float l = 1, float a = 1, float b = 1) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL * l, cA * a, cB * b); @@ -97,7 +97,7 @@ public static Color MultiplyLab(this in Color color, float l = 1, float a = 1, f /// The a value to divide. /// The b value to divide. /// The new color after the modification. - public static Color DivideLab(this in Color color, float l = 1, float a = 1, float b = 1) + public static Color DivideLab(this Color color, float l = 1, float a = 1, float b = 1) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, cL / l, cA / a, cB / b); @@ -111,7 +111,7 @@ public static Color DivideLab(this in Color color, float l = 1, float a = 1, flo /// The a value to set. /// The b value to set. /// The new color after the modification. - public static Color SetLab(this in Color color, float? l = null, float? a = null, float? b = null) + public static Color SetLab(this Color color, float? l = null, float? a = null, float? b = null) { (float cL, float cA, float cB) = color.GetLab(); return Create(color.A, l ?? cL, a ?? cA, b ?? cB); diff --git a/RGB.NET.Core/Color/RGBColor.cs b/RGB.NET.Core/Color/RGBColor.cs index 9ffa528d..4b61189e 100644 --- a/RGB.NET.Core/Color/RGBColor.cs +++ b/RGB.NET.Core/Color/RGBColor.cs @@ -16,35 +16,35 @@ public static class RGBColor /// /// The color to get the value from. /// The A component value of the color. - public static byte GetA(this in Color color) => color.A.GetByteValueFromPercentage(); + public static byte GetA(this Color color) => color.A.GetByteValueFromPercentage(); /// /// Gets the R component value of this as byte in the range [0..255]. /// /// The color to get the value from. /// The R component value of the color. - public static byte GetR(this in Color color) => color.R.GetByteValueFromPercentage(); + public static byte GetR(this Color color) => color.R.GetByteValueFromPercentage(); /// /// Gets the G component value of this as byte in the range [0..255]. /// /// The color to get the value from. /// The G component value of the color. - public static byte GetG(this in Color color) => color.G.GetByteValueFromPercentage(); + public static byte GetG(this Color color) => color.G.GetByteValueFromPercentage(); /// /// Gets the B component value of this as byte in the range [0..255]. /// /// The color to get the value from. /// The B component value of the color. - public static byte GetB(this in Color color) => color.B.GetByteValueFromPercentage(); + public static byte GetB(this Color color) => color.B.GetByteValueFromPercentage(); /// /// Gets the A, R, G and B component value of this as byte in the range [0..255]. /// /// The color to get the value from. /// A tuple containing the A, R, G and B component value of the color. - public static (byte a, byte r, byte g, byte b) GetRGBBytes(this in Color color) + public static (byte a, byte r, byte g, byte b) GetRGBBytes(this Color color) => (color.GetA(), color.GetR(), color.GetG(), color.GetB()); /// @@ -52,7 +52,7 @@ public static (byte a, byte r, byte g, byte b) GetRGBBytes(this in Color color) /// /// The color to get the value from. /// A tuple containing the A, R, G and B component value of the color. - public static (float a, float r, float g, float b) GetRGB(this in 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 @@ -69,7 +69,7 @@ public static (float a, float r, float g, float b) GetRGB(this in Color color) /// The green value to add. /// The blue value to add. /// The new color after the modification. - public static Color AddRGB(this in Color color, int r = 0, int g = 0, int b = 0) + public static Color AddRGB(this Color color, int r = 0, int g = 0, int b = 0) => new(color.A, color.GetR() + r, color.GetG() + g, color.GetB() + b); /// @@ -80,7 +80,7 @@ public static Color AddRGB(this in Color color, int r = 0, int g = 0, int b = 0) /// The green value to add. /// The blue value to add. /// The new color after the modification. - public static Color AddRGB(this in Color color, float r = 0, float g = 0, float 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); /// @@ -89,7 +89,7 @@ public static Color AddRGB(this in Color color, float r = 0, float g = 0, float /// The color to modify. /// The alpha value to add. /// The new color after the modification. - public static Color AddA(this in Color color, int a) + public static Color AddA(this Color color, int a) => new(color.GetA() + a, color.R, color.G, color.B); /// @@ -98,7 +98,7 @@ public static Color AddA(this in Color color, int a) /// The color to modify. /// The alpha value to add. /// The new color after the modification. - public static Color AddA(this in Color color, float a) + public static Color AddA(this Color color, float a) => new(color.A + a, color.R, color.G, color.B); #endregion @@ -113,7 +113,7 @@ public static Color AddA(this in Color color, float a) /// The green value to subtract. /// The blue value to subtract. /// The new color after the modification. - public static Color SubtractRGB(this in Color color, int r = 0, int g = 0, int b = 0) + public static Color SubtractRGB(this Color color, int r = 0, int g = 0, int b = 0) => new(color.A, color.GetR() - r, color.GetG() - g, color.GetB() - b); /// @@ -124,7 +124,7 @@ public static Color SubtractRGB(this in Color color, int r = 0, int g = 0, int b /// The green value to subtract. /// The blue value to subtract. /// The new color after the modification. - public static Color SubtractRGB(this in Color color, float r = 0, float g = 0, float 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); /// @@ -133,7 +133,7 @@ public static Color SubtractRGB(this in Color color, float r = 0, float g = 0, f /// The color to modify. /// The alpha value to subtract. /// The new color after the modification. - public static Color SubtractA(this in Color color, int a) + public static Color SubtractA(this Color color, int a) => new(color.GetA() - a, color.R, color.G, color.B); /// @@ -142,7 +142,7 @@ public static Color SubtractA(this in Color color, int a) /// The color to modify. /// The alpha value to subtract. /// The new color after the modification. - public static Color SubtractA(this in Color color, float aPercent) + public static Color SubtractA(this Color color, float aPercent) => new(color.A - aPercent, color.R, color.G, color.B); #endregion @@ -157,7 +157,7 @@ public static Color SubtractA(this in Color color, float aPercent) /// The green value to multiply. /// The blue value to multiply. /// The new color after the modification. - public static Color MultiplyRGB(this in Color color, float r = 1, float g = 1, float 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); /// @@ -166,7 +166,7 @@ public static Color MultiplyRGB(this in Color color, float r = 1, float g = 1, f /// The color to modify. /// The alpha value to multiply. /// The new color after the modification. - public static Color MultiplyA(this in Color color, float a) + public static Color MultiplyA(this Color color, float a) => new(color.A * a, color.R, color.G, color.B); #endregion @@ -181,7 +181,7 @@ public static Color MultiplyA(this in Color color, float a) /// The green value to divide. /// The blue value to divide. /// The new color after the modification. - public static Color DivideRGB(this in Color color, float r = 1, float g = 1, float 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); /// @@ -190,7 +190,7 @@ public static Color DivideRGB(this in Color color, float r = 1, float g = 1, flo /// The color to modify. /// The alpha value to divide. /// The new color after the modification. - public static Color DivideA(this in Color color, float a) + public static Color DivideA(this Color color, float a) => new(color.A / a, color.R, color.G, color.B); #endregion @@ -205,7 +205,7 @@ public static Color DivideA(this in Color color, float a) /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, byte? r = null, byte? g = null, byte? b = null) + public static Color SetRGB(this Color color, byte? r = null, byte? g = null, byte? b = null) => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// @@ -216,7 +216,7 @@ public static Color SetRGB(this in Color color, byte? r = null, byte? g = null, /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, int? r = null, int? g = null, int? b = null) + public static Color SetRGB(this Color color, int? r = null, int? g = null, int? b = null) => new(color.A, r ?? color.GetR(), g ?? color.GetG(), b ?? color.GetB()); /// @@ -227,7 +227,7 @@ public static Color SetRGB(this in Color color, int? r = null, int? g = null, in /// The green value to set. /// The blue value to set. /// The new color after the modification. - public static Color SetRGB(this in Color color, float? r = null, float? g = null, float? 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); /// @@ -236,7 +236,7 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// The color to modify. /// The alpha value to set. /// The new color after the modification. - public static Color SetA(this in Color color, int a) => new(a, color.R, color.G, color.B); + public static Color SetA(this Color color, int a) => new(a, color.R, color.G, color.B); /// /// Sets the specified alpha value of this color. @@ -244,7 +244,7 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// The color to modify. /// The alpha value to set. /// The new color after the modification. - public static Color SetA(this in Color color, float 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 @@ -256,13 +256,13 @@ public static Color SetRGB(this in Color color, float? r = null, float? g = null /// Gets the current color as a RGB-HEX-string. /// /// The RGB-HEX-string. - public static string AsRGBHexString(this in Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetR(), color.GetG(), color.GetB()); + public static string AsRGBHexString(this Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetR(), color.GetG(), color.GetB()); /// /// Gets the current color as a ARGB-HEX-string. /// /// The ARGB-HEX-string. - public static string AsARGBHexString(this in Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetA(), color.GetR(), color.GetG(), color.GetB()); + public static string AsARGBHexString(this Color color, bool leadingHash = true) => (leadingHash ? "#" : "") + ConversionHelper.ToHex(color.GetA(), color.GetR(), color.GetG(), color.GetB()); #endregion diff --git a/RGB.NET.Core/Color/XYZColor.cs b/RGB.NET.Core/Color/XYZColor.cs index 168d4f73..a20f5ace 100644 --- a/RGB.NET.Core/Color/XYZColor.cs +++ b/RGB.NET.Core/Color/XYZColor.cs @@ -16,21 +16,21 @@ public static class XYZColor /// /// The color to get the value from. /// The X component value of the color. - public static float GetX(this in Color color) => color.GetXYZ().x; + public static float GetX(this Color color) => color.GetXYZ().x; /// /// Gets the Y component value (XYZ-color space) of this in the range [0..100]. /// /// The color to get the value from. /// The Y component value of the color. - public static float GetY(this in Color color) => color.GetXYZ().y; + public static float GetY(this Color color) => color.GetXYZ().y; /// /// Gets the Z component value (XYZ-color space) of this in the range [0..108.883]. /// /// The color to get the value from. /// The Z component value of the color. - public static float GetZ(this in Color color) => color.GetXYZ().z; + public static float GetZ(this Color color) => color.GetXYZ().z; /// /// Gets the X, Y and Z component values (XYZ-color space) of this . @@ -40,7 +40,7 @@ public static class XYZColor /// /// The color to get the value from. /// A tuple containing the X, Y and Z component value of the color. - public static (float x, float y, float z) GetXYZ(this in Color color) + public static (float x, float y, float z) GetXYZ(this Color color) => CaclulateXYZFromRGB(color.R, color.G, color.B); #endregion @@ -55,7 +55,7 @@ public static (float x, float y, float z) GetXYZ(this in Color color) /// The Y value to add. /// The Z value to add. /// The new color after the modification. - public static Color AddXYZ(this in Color color, float x = 0, float y = 0, float z = 0) + public static Color AddXYZ(this Color color, float x = 0, float y = 0, float z = 0) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX + x, cY + y, cZ + z); @@ -69,7 +69,7 @@ public static Color AddXYZ(this in Color color, float x = 0, float y = 0, float /// The Y value to subtract. /// The Z value to subtract. /// The new color after the modification. - public static Color SubtractXYZ(this in Color color, float x = 0, float y = 0, float z = 0) + public static Color SubtractXYZ(this Color color, float x = 0, float y = 0, float z = 0) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX - x, cY - y, cZ - z); @@ -83,7 +83,7 @@ public static Color SubtractXYZ(this in Color color, float x = 0, float y = 0, f /// The Y value to multiply. /// The Z value to multiply. /// The new color after the modification. - public static Color MultiplyXYZ(this in Color color, float x = 1, float y = 1, float z = 1) + public static Color MultiplyXYZ(this Color color, float x = 1, float y = 1, float z = 1) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX * x, cY * y, cZ * z); @@ -97,7 +97,7 @@ public static Color MultiplyXYZ(this in Color color, float x = 1, float y = 1, f /// The Y value to divide. /// The Z value to divide. /// The new color after the modification. - public static Color DivideXYZ(this in Color color, float x = 1, float y = 1, float z = 1) + public static Color DivideXYZ(this Color color, float x = 1, float y = 1, float z = 1) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, cX / x, cY / y, cZ / z); @@ -111,7 +111,7 @@ public static Color DivideXYZ(this in Color color, float x = 1, float y = 1, flo /// The Y value to set. /// The Z value to set. /// The new color after the modification. - public static Color SetXYZ(this in Color color, float? x = null, float? y = null, float? z = null) + public static Color SetXYZ(this Color color, float? x = null, float? y = null, float? z = null) { (float cX, float cY, float cZ) = color.GetXYZ(); return Create(color.A, x ?? cX, y ?? cY, z ?? cZ); diff --git a/RGB.NET.Core/Decorators/IBrushDecorator.cs b/RGB.NET.Core/Decorators/IBrushDecorator.cs index ec1c4325..89594b7c 100644 --- a/RGB.NET.Core/Decorators/IBrushDecorator.cs +++ b/RGB.NET.Core/Decorators/IBrushDecorator.cs @@ -12,5 +12,5 @@ public interface IBrushDecorator : IDecorator /// The rectangle in which the should be drawn. /// The target (key/point) from which the should be taken. /// The to be modified. - void ManipulateColor(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color); + void ManipulateColor(Rectangle rectangle, RenderTarget renderTarget, ref Color color); } \ No newline at end of file diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 9e3572b3..f4db90ef 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -179,7 +179,7 @@ protected virtual void DeviceUpdate() { } /// - public virtual Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null) + public virtual Led? AddLed(LedId ledId, Point location, Size size, object? customData = null) { if ((ledId == LedId.Invalid) || LedMapping.ContainsKey(ledId)) return null; diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index 6e79fb3f..ce9dbd23 100644 --- a/RGB.NET.Core/Devices/IRGBDevice.cs +++ b/RGB.NET.Core/Devices/IRGBDevice.cs @@ -72,7 +72,7 @@ public interface IRGBDevice : IEnumerable, IPlaceable, IBindable, IDisposab /// The size of the led. /// Custom data saved on the led. /// The newly added led or null if a led with this id is already added. - Led? AddLed(LedId ledId, in Point location, in Size size, object? customData = null); + Led? AddLed(LedId ledId, Point location, Size size, object? customData = null); /// /// Removes the led with the specified id from the device. diff --git a/RGB.NET.Core/Extensions/ColorExtensions.cs b/RGB.NET.Core/Extensions/ColorExtensions.cs index c2afc234..de3756ad 100644 --- a/RGB.NET.Core/Extensions/ColorExtensions.cs +++ b/RGB.NET.Core/Extensions/ColorExtensions.cs @@ -16,7 +16,7 @@ public static class ColorExtensions /// The start color of the distance calculation. /// The end color fot the distance calculation. /// The redmean distance between the two specified colors. - public static double DistanceTo(this in Color color1, in Color color2) + public static double DistanceTo(this Color color1, Color color2) { (_, byte r1, byte g1, byte b1) = color1.GetRGBBytes(); (_, byte r2, byte g2, byte b2) = color2.GetRGBBytes(); diff --git a/RGB.NET.Core/Extensions/MathExtensions.cs b/RGB.NET.Core/Extensions/MathExtensions.cs index 665df6a3..93107b64 100644 --- a/RGB.NET.Core/Extensions/MathExtensions.cs +++ b/RGB.NET.Core/Extensions/MathExtensions.cs @@ -91,9 +91,11 @@ public static float Wrap(this float value, float min, float max) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte GetByteValueFromPercentage(this float percentage) { + // ReSharper disable once ConvertIfStatementToSwitchStatement - This results in a bit more instructions if (float.IsNaN(percentage) || (percentage <= 0)) return 0; + if (percentage >= 1.0f) return byte.MaxValue; - return (byte)(percentage >= 1.0f ? 255 : percentage * 256.0f); + return (byte)(percentage * 256.0f); } /// diff --git a/RGB.NET.Core/Extensions/PointExtensions.cs b/RGB.NET.Core/Extensions/PointExtensions.cs index 1acab3a7..747098cb 100644 --- a/RGB.NET.Core/Extensions/PointExtensions.cs +++ b/RGB.NET.Core/Extensions/PointExtensions.cs @@ -16,7 +16,7 @@ public static class PointExtensions /// The x-ammount to move. /// The y-ammount to move. /// The new location of the point. - public static Point Translate(this in Point point, float x = 0, float 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 specified amuont around the specified origin. @@ -25,7 +25,7 @@ public static class PointExtensions /// The rotation. /// The origin to rotate around. [0,0] if not set. /// The new location of the point. - public static Point Rotate(this in Point point, in Rotation rotation, in Point origin = new()) + public static Point Rotate(this Point point, Rotation rotation, Point origin = new()) { float sin = MathF.Sin(rotation.Radians); float cos = MathF.Cos(rotation.Radians); diff --git a/RGB.NET.Core/Extensions/RectangleExtensions.cs b/RGB.NET.Core/Extensions/RectangleExtensions.cs index c97256fd..741742b8 100644 --- a/RGB.NET.Core/Extensions/RectangleExtensions.cs +++ b/RGB.NET.Core/Extensions/RectangleExtensions.cs @@ -15,7 +15,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new location of the rectangle. /// The modified . - public static Rectangle SetLocation(this in Rectangle rect, in Point location) => new(location, rect.Size); + public static Rectangle SetLocation(this Rectangle rect, Point location) => new(location, rect.Size); /// /// Sets the of the of the specified rectangle. @@ -23,7 +23,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new x-location of the rectangle. /// The modified . - public static Rectangle SetX(this in Rectangle rect, float 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 specified rectangle. @@ -31,7 +31,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new y-location of the rectangle. /// The modified . - public static Rectangle SetY(this in Rectangle rect, float 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 specified rectangle. @@ -39,7 +39,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new size of the rectangle. /// The modified . - public static Rectangle SetSize(this in Rectangle rect, in Size size) => new(rect.Location, size); + public static Rectangle SetSize(this Rectangle rect, Size size) => new(rect.Location, size); /// /// Sets the of the of the specified rectangle. @@ -47,7 +47,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new width of the rectangle. /// The modified . - public static Rectangle SetWidth(this in Rectangle rect, float 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 specified rectangle. @@ -55,7 +55,7 @@ public static class RectangleExtensions /// The rectangle to modify. /// The new height of the rectangle. /// The modified . - public static Rectangle SetHeight(this in Rectangle rect, float 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. @@ -63,7 +63,7 @@ public static class RectangleExtensions /// The rectangle to calculate the intersection for. /// The intersecting rectangle. /// The percentage of intersection. - public static float CalculateIntersectPercentage(this in Rectangle rect, in Rectangle intersectingRect) + public static float CalculateIntersectPercentage(this Rectangle rect, Rectangle intersectingRect) { if (rect.IsEmpty || intersectingRect.IsEmpty) return 0; @@ -77,7 +77,7 @@ public static float CalculateIntersectPercentage(this in Rectangle rect, in Rect /// The rectangle to calculate the intersection for. /// The intersecting . /// A new representing the intersection this and the one provided as parameter. - public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectangle intersectingRectangle) + public static Rectangle CalculateIntersection(this Rectangle rect, Rectangle intersectingRectangle) { 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); @@ -97,7 +97,7 @@ public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectang /// The containing rectangle. /// The to test. /// true if the rectangle contains the specified point; otherwise false. - public static bool Contains(this in Rectangle rect, in Point point) => rect.Contains(point.X, point.Y); + public static bool Contains(this Rectangle rect, Point point) => rect.Contains(point.X, point.Y); /// /// Determines if the specified location is contained within this . @@ -106,7 +106,7 @@ public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectang /// The X-location to test. /// The Y-location to test. /// true if the rectangle contains the specified coordinates; otherwise false. - public static bool Contains(this in Rectangle rect, float x, float 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)); /// @@ -115,7 +115,7 @@ public static bool Contains(this in Rectangle rect, float x, float y) => (rect.L /// The containing rectangle. /// The to test. /// true if the rectangle contains the specified rect; otherwise false. - public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect.Location.X <= rect2.Location.X) && ((rect2.Location.X + rect2.Size.Width) <= (rect.Location.X + rect.Size.Width)) + public static bool Contains(this Rectangle rect, Rectangle rect2) => (rect.Location.X <= rect2.Location.X) && ((rect2.Location.X + rect2.Size.Width) <= (rect.Location.X + rect.Size.Width)) && (rect.Location.Y <= rect2.Location.Y) && ((rect2.Location.Y + rect2.Size.Height) <= (rect.Location.Y + rect.Size.Height)); /// @@ -124,7 +124,7 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The to move. /// The amount to move. /// The moved rectangle. - public static Rectangle Translate(this in Rectangle rect, in Point point) => rect.Translate(point.X, point.Y); + public static Rectangle Translate(this Rectangle rect, Point point) => rect.Translate(point.X, point.Y); /// /// Moves the specified by the specified amount. @@ -133,7 +133,7 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The x-ammount to move. /// The y-ammount to move. /// The moved rectangle. - public static Rectangle Translate(this in Rectangle rect, float x = 0, float 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 specified amuont around the specified origin. @@ -149,7 +149,7 @@ public static bool Contains(this in Rectangle rect, in Rectangle rect2) => (rect /// The rotation. /// The origin to rotate around. [0,0] if not set. /// A array of containing the new locations of the corners of the original rectangle. - public static Point[] Rotate(this in Rectangle rect, in Rotation rotation, in Point origin = new()) + public static Point[] Rotate(this Rectangle rect, Rotation rotation, Point origin = new()) { Point[] points = [ diff --git a/RGB.NET.Core/Positioning/Point.cs b/RGB.NET.Core/Positioning/Point.cs index e92c65f3..b8f15e72 100644 --- a/RGB.NET.Core/Positioning/Point.cs +++ b/RGB.NET.Core/Positioning/Point.cs @@ -90,7 +90,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Point point1, in Point point2) => point1.Equals(point2); + public static bool operator ==(Point point1, Point point2) => point1.Equals(point2); /// /// Returns a value that indicates whether two specified are equal. @@ -98,7 +98,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Point point1, in Point point2) => !(point1 == point2); + public static bool operator !=(Point point1, Point point2) => !(point1 == point2); /// /// Returns a new representing the addition of the two provided . @@ -106,7 +106,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the addition of the two provided . - public static Point operator +(in Point point1, in Point point2) => new(point1.X + point2.X, point1.Y + point2.Y); + public static Point operator +(Point point1, Point point2) => new(point1.X + point2.X, point1.Y + point2.Y); /// /// Returns a new created from the provided and . @@ -114,7 +114,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The of the rectangle. /// The of the rectangle. /// The rectangle created from the provided and . - public static Rectangle operator +(in Point point, in Size size) => new(point, size); + public static Rectangle operator +(Point point, Size size) => new(point, size); /// /// Returns a new representing the subtraction of the two provided . @@ -122,7 +122,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the subtraction of the two provided . - public static Point operator -(in Point point1, in Point point2) => new(point1.X - point2.X, point1.Y - point2.Y); + public static Point operator -(Point point1, Point point2) => new(point1.X - point2.X, point1.Y - point2.Y); /// /// Returns a new representing the multiplication of the two provided . @@ -130,7 +130,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the multiplication of the two provided . - public static Point operator *(in Point point1, in Point point2) => new(point1.X * point2.X, point1.Y * point2.Y); + public static Point operator *(Point point1, Point point2) => new(point1.X * point2.X, point1.Y * point2.Y); /// /// Returns a new representing the division of the two provided . @@ -138,7 +138,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The first . /// The second . /// A new representing the division of the two provided . - public static Point operator /(in Point point1, in Point point2) + public static Point operator /(Point point1, Point point2) { if (point2.X.EqualsInTolerance(0) || point2.Y.EqualsInTolerance(0)) return Invalid; return new Point(point1.X / point2.X, point1.Y / point2.Y); @@ -150,7 +150,7 @@ public bool Equals(Point other) => ((float.IsNaN(X) && float.IsNaN(other.X)) || /// The . /// The . /// A new representing the multiplication of the and the provided . - public static Point operator *(in Point point, in Scale scale) => new(point.X * scale.Horizontal, point.Y * scale.Vertical); + public static Point operator *(Point point, Scale scale) => new(point.X * scale.Horizontal, point.Y * scale.Vertical); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index 095a210e..a1cf4de6 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -179,7 +179,7 @@ internal Rectangle(IList leds) #region Methods - private static (Point location, Size size) InitializeFromPoints(in Point point1, in Point point2) + private static (Point location, Size size) InitializeFromPoints(Point point1, Point point2) { float posX = Math.Min(point1.X, point2.X); float posY = Math.Min(point1.Y, point2.Y); @@ -225,7 +225,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Rectangle rectangle1, in Rectangle rectangle2) => rectangle1.Equals(rectangle2); + public static bool operator ==(Rectangle rectangle1, Rectangle rectangle2) => rectangle1.Equals(rectangle2); /// /// Returns a value that indicates whether two specified are equal. @@ -233,7 +233,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Rectangle rectangle1, in Rectangle rectangle2) => !(rectangle1 == rectangle2); + public static bool operator !=(Rectangle rectangle1, Rectangle rectangle2) => !(rectangle1 == rectangle2); // DarthAffe 20.02.2021: Used for normalization /// @@ -242,7 +242,7 @@ private static (Point location, Size size) InitializeFromPoints(in Point point1, /// The rectangle to nromalize. /// The reference used for normalization. /// A normalized rectangle. - public static Rectangle operator /(in Rectangle rectangle1, in Rectangle rectangle2) + public static Rectangle operator /(Rectangle rectangle1, Rectangle rectangle2) { float x = rectangle1.Location.X / (rectangle2.Size.Width - rectangle2.Location.X); float y = rectangle1.Location.Y / (rectangle2.Size.Height - rectangle2.Location.Y); diff --git a/RGB.NET.Core/Positioning/Rotation.cs b/RGB.NET.Core/Positioning/Rotation.cs index e204b757..4b6732b6 100644 --- a/RGB.NET.Core/Positioning/Rotation.cs +++ b/RGB.NET.Core/Positioning/Rotation.cs @@ -103,7 +103,7 @@ private Rotation(float degrees, float radians) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Rotation rotation1, in Rotation rotation2) => rotation1.Equals(rotation2); + public static bool operator ==(Rotation rotation1, Rotation rotation2) => rotation1.Equals(rotation2); /// /// Returns a value that indicates whether two specified are equal. @@ -111,7 +111,7 @@ private Rotation(float degrees, float radians) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Rotation rotation1, in Rotation rotation2) => !(rotation1 == rotation2); + public static bool operator !=(Rotation rotation1, Rotation rotation2) => !(rotation1 == rotation2); /// /// Returns a new representing the addition of the and the provided value. @@ -119,7 +119,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to add. /// A new representing the addition of the and the provided value. - public static Rotation operator +(in Rotation rotation, float 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 @@ private Rotation(float degrees, float radians) /// The . /// The value to substract. /// A new representing the subtraction of the and the provided value. - public static Rotation operator -(in Rotation rotation, float 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 @@ private Rotation(float degrees, float radians) /// The . /// The value to multiply with. /// A new representing the multiplication of the and the provided value. - public static Rotation operator *(in Rotation rotation, float 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,7 +143,7 @@ private Rotation(float degrees, float radians) /// The . /// The value to device with. /// A new representing the division of the and the provided value. - public static Rotation operator /(in Rotation rotation, float 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 float to a . @@ -155,7 +155,7 @@ private Rotation(float degrees, float radians) /// Converts to a float representing the rotation in degrees. /// /// The rotatio to convert. - public static implicit operator float(in Rotation rotation) => rotation.Degrees; + public static implicit operator float(Rotation rotation) => rotation.Degrees; #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Positioning/Size.cs b/RGB.NET.Core/Positioning/Size.cs index 1a9a6d63..22704494 100644 --- a/RGB.NET.Core/Positioning/Size.cs +++ b/RGB.NET.Core/Positioning/Size.cs @@ -110,7 +110,7 @@ public void Deconstruct(out float width, out float height) /// The first to compare. /// The second to compare. /// true if and are equal; otherwise, false. - public static bool operator ==(in Size size1, in Size size2) => size1.Equals(size2); + public static bool operator ==(Size size1, Size size2) => size1.Equals(size2); /// /// Returns a value that indicates whether two specified are equal. @@ -118,7 +118,7 @@ public void Deconstruct(out float width, out float height) /// The first to compare. /// The second to compare. /// true if and are not equal; otherwise, false. - public static bool operator !=(in Size size1, in Size size2) => !(size1 == size2); + public static bool operator !=(Size size1, Size size2) => !(size1 == size2); /// /// Returns a new representing the addition of the two provided . @@ -126,7 +126,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the addition of the two provided . - public static Size operator +(in Size size1, in Size size2) => new(size1.Width + size2.Width, size1.Height + size2.Height); + public static Size operator +(Size size1, Size size2) => new(size1.Width + size2.Width, size1.Height + size2.Height); /// /// Returns a new created from the provided and . @@ -134,7 +134,7 @@ public void Deconstruct(out float width, out float height) /// The of the rectangle. /// The of the rectangle. /// The rectangle created from the provided and . - public static Rectangle operator +(in Size size, in Point point) => new(point, size); + public static Rectangle operator +(Size size, Point point) => new(point, size); /// /// Returns a new representing the subtraction of the two provided . @@ -142,7 +142,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the subtraction of the two provided . - public static Size operator -(in Size size1, in Size size2) => new(size1.Width - size2.Width, size1.Height - size2.Height); + public static Size operator -(Size size1, Size size2) => new(size1.Width - size2.Width, size1.Height - size2.Height); /// /// Returns a new representing the multiplication of the two provided . @@ -150,7 +150,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the multiplication of the two provided . - public static Size operator *(in Size size1, in Size size2) => new(size1.Width * size2.Width, size1.Height * size2.Height); + public static Size operator *(Size size1, Size size2) => new(size1.Width * size2.Width, size1.Height * size2.Height); /// /// Returns a new representing the multiplication of the and the provided factor. @@ -158,7 +158,7 @@ public void Deconstruct(out float width, out float height) /// The . /// The factor by which the should be multiplied. /// A new representing the multiplication of the and the provided factor. - public static Size operator *(in Size size, float 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 . @@ -166,7 +166,7 @@ public void Deconstruct(out float width, out float height) /// The first . /// The second . /// A new representing the division of the two provided . - public static Size operator /(in Size size1, in Size size2) + public static Size operator /(Size size1, Size size2) => size2.Width.EqualsInTolerance(0) || size2.Height.EqualsInTolerance(0) ? Invalid : new Size(size1.Width / size2.Width, size1.Height / size2.Height); @@ -176,7 +176,7 @@ public void Deconstruct(out float width, out float height) /// The . /// The factor by which the should be divided. /// A new representing the division of the and the provided factor. - public static Size operator /(in Size size, float 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 specified . @@ -184,7 +184,7 @@ public void Deconstruct(out float width, out float height) /// The to scale. /// The scaling factor. /// A new representing the multiplication of the and the specified . - public static Size operator *(in Size size, in Scale scale) => new(size.Width * scale.Horizontal, size.Height * scale.Vertical); + public static Size operator *(Size size, Scale scale) => new(size.Width * scale.Horizontal, size.Height * scale.Vertical); #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs index bc39b5d3..dc69fb21 100644 --- a/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/AbstractBrush.cs @@ -69,7 +69,7 @@ protected AbstractBrush(float brightness = 1, float opacity = 1) /// The rectangle in which the brush should be drawn. /// The target (key/point) from which the color should be taken. /// The to be modified. - protected virtual void ApplyDecorators(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color) + protected virtual void ApplyDecorators(Rectangle rectangle, RenderTarget renderTarget, ref Color color) { if (Decorators.Count == 0) return; @@ -89,7 +89,7 @@ protected virtual void ApplyDecorators(in Rectangle rectangle, in RenderTarget r /// The rectangle in which the brush should be drawn. /// The target (key/point) from which the color should be taken. /// The color at the specified point. - protected abstract Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget); + protected abstract Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget); /// /// Finalizes the color by appliing the overall brightness and opacity.
diff --git a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs index 02f8e2db..33464b68 100644 --- a/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/SolidColorBrush.cs @@ -41,7 +41,7 @@ public SolidColorBrush(Color color) #region Methods /// - protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) => Color; + protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) => Color; #endregion diff --git a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs index 41280cd2..3881545f 100644 --- a/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs +++ b/RGB.NET.Core/Rendering/Brushes/TextureBrush.cs @@ -36,7 +36,7 @@ public TextureBrush(ITexture texture) #region Methods /// - protected override Color GetColorAtPoint(in Rectangle rectangle, in RenderTarget renderTarget) + protected override Color GetColorAtPoint(Rectangle rectangle, RenderTarget renderTarget) { Rectangle normalizedRect = renderTarget.Rectangle / rectangle; return Texture[normalizedRect]; diff --git a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs index 7aca9b7a..28152f42 100644 --- a/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/EmptyTexture.cs @@ -5,8 +5,8 @@ internal sealed class EmptyTexture : ITexture #region Properties & Fields public Size Size { get; } = new(0, 0); - public Color this[in Point point] => Color.Transparent; - public Color this[in Rectangle rectangle] => Color.Transparent; + public Color this[Point point] => Color.Transparent; + public Color this[Rectangle rectangle] => Color.Transparent; #endregion } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/ITexture.cs b/RGB.NET.Core/Rendering/Textures/ITexture.cs index 8fdd2ae7..93773bba 100644 --- a/RGB.NET.Core/Rendering/Textures/ITexture.cs +++ b/RGB.NET.Core/Rendering/Textures/ITexture.cs @@ -20,12 +20,12 @@ public interface ITexture ///
/// The location to get the color from. /// The color at the specified location. - Color this[in Point point] { get; } + Color this[Point point] { get; } /// /// Gets the sampled color inside the specified rectangle. /// /// The rectangle to get the color from. /// The sampled color. - Color this[in Rectangle rectangle] { get; } + Color this[Rectangle rectangle] { get; } } \ No newline at end of file diff --git a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs index 5ad4459b..40478408 100644 --- a/RGB.NET.Core/Rendering/Textures/PixelTexture.cs +++ b/RGB.NET.Core/Rendering/Textures/PixelTexture.cs @@ -39,7 +39,7 @@ public abstract class PixelTexture : ITexture public Size Size { get; } /// - public virtual Color this[in Point point] + public virtual Color this[Point point] { get { @@ -52,7 +52,7 @@ public virtual Color this[in Point point] } /// - public virtual Color this[in Rectangle rectangle] + public virtual Color this[Rectangle rectangle] { get { diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs index f7e3258b..24f4dfb3 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/AverageColorSampler.cs @@ -22,7 +22,7 @@ public sealed class AverageColorSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, Span pixelData) + public unsafe void Sample(SamplerInfo info, Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs index 04fcfa08..7461afd9 100644 --- a/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs +++ b/RGB.NET.Core/Rendering/Textures/Sampler/ISampler.cs @@ -13,5 +13,5 @@ public interface ISampler ///
/// The information containing the data to sample. /// The buffer used to write the resulting pixel to. - void Sample(in SamplerInfo info, Span pixelData); + void Sample(SamplerInfo info, Span pixelData); } \ No newline at end of file diff --git a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs index 987b691e..1eb0548d 100644 --- a/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/LimitedColorUpdateQueue.cs @@ -25,7 +25,7 @@ public LimitedColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) #region Methods /// - protected override ShortMessage CreateMessage(object key, in Color color) + protected override ShortMessage CreateMessage(object key, Color color) { (byte mode, byte id) = ((byte, byte))key; return new ShortMessage(mode, id, Convert.ToByte(ConvertColor(color))); @@ -37,7 +37,7 @@ protected override ShortMessage CreateMessage(object key, in Color color) ///
/// The to convert. /// The novation-representation of the . - private static int ConvertColor(in Color color) + private static int ConvertColor(Color color) { (double hue, double _, double value) = color.GetHSV(); diff --git a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs index 4cc8929b..8b451762 100644 --- a/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/MidiUpdateQueue.cs @@ -68,7 +68,7 @@ protected virtual void SendMessage(ShortMessage? message) /// The key used to identify the LED to update. /// The color to send. /// The message created out of the data set. - protected abstract ShortMessage? CreateMessage(object key, in Color color); + protected abstract ShortMessage? CreateMessage(object key, Color color); /// public override void Dispose() diff --git a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs index aa3f53d5..0584d45f 100644 --- a/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs +++ b/RGB.NET.Devices.Novation/Generic/RGBColorUpdateQueue.cs @@ -151,7 +151,7 @@ public RGBColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) #region Methods /// - protected override ShortMessage? CreateMessage(object key, in Color color) + protected override ShortMessage? CreateMessage(object key, Color color) { (byte mode, byte id) = ((byte, byte))key; if (mode == 0x00) return null; @@ -165,7 +165,7 @@ public RGBColorUpdateQueue(IDeviceUpdateTrigger updateTrigger, int deviceId) ///
/// The to convert. /// The novation-representation of the . - private static int ConvertColor(in Color color) + private static int ConvertColor(Color color) { int bestVelocity = 0; double bestMatchDistance = double.MaxValue; diff --git a/RGB.NET.Presets/Decorators/FlashDecorator.cs b/RGB.NET.Presets/Decorators/FlashDecorator.cs index e30a5f28..ab70266d 100644 --- a/RGB.NET.Presets/Decorators/FlashDecorator.cs +++ b/RGB.NET.Presets/Decorators/FlashDecorator.cs @@ -90,7 +90,7 @@ public FlashDecorator(RGBSurface surface, bool updateIfDisabled = false) #region Methods /// - public void ManipulateColor(in Rectangle rectangle, in RenderTarget renderTarget, ref Color color) => color = color.SetA(_currentValue); + public void ManipulateColor(Rectangle rectangle, RenderTarget renderTarget, ref Color color) => color = color.SetA(_currentValue); /// protected override void Update(double deltaTime) diff --git a/RGB.NET.Presets/Helper/GradientHelper.cs b/RGB.NET.Presets/Helper/GradientHelper.cs index 2f6d68d9..86459790 100644 --- a/RGB.NET.Presets/Helper/GradientHelper.cs +++ b/RGB.NET.Presets/Helper/GradientHelper.cs @@ -20,7 +20,7 @@ public static class GradientHelper /// The end of the gradient. /// The on the gradient to which the offset is calculated. /// The offset of the on the gradient. - public static float CalculateLinearGradientOffset(in Point startPoint, in Point endPoint, in Point point) + public static float CalculateLinearGradientOffset(Point startPoint, Point endPoint, Point point) { Point intersectingPoint; if (startPoint.Y.EqualsInTolerance(endPoint.Y)) // Horizontal case @@ -57,7 +57,7 @@ public static float CalculateLinearGradientOffset(in Point startPoint, in Point /// The origin of the vector. /// The direction of the vector. /// The signed magnitude of a on a vector. - public static float CalculateDistance(in Point point, in Point origin, in Point direction) + public static float CalculateDistance(Point point, Point origin, Point direction) { float distance = CalculateDistance(point, origin); @@ -74,7 +74,7 @@ public static float CalculateDistance(in Point point, in Point origin, in Point /// The first . /// The second . /// The distance between the two . - public static float CalculateDistance(in Point point1, in Point point2) + public static float CalculateDistance(Point point1, Point point2) { float x = point1.X - point2.X; float y = point1.Y - point2.Y; diff --git a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs index 3f2f73c2..e4b6b888 100644 --- a/RGB.NET.Presets/Textures/AbstractGradientTexture.cs +++ b/RGB.NET.Presets/Textures/AbstractGradientTexture.cs @@ -21,10 +21,10 @@ public abstract class AbstractGradientTexture : AbstractBindable, ITexture public Size Size { get; } /// - public Color this[in Point point] => GetColor(point); + public Color this[Point point] => GetColor(point); /// - public Color this[in Rectangle rectangle] => GetColor(rectangle.Center); + public Color this[Rectangle rectangle] => GetColor(rectangle.Center); #endregion @@ -50,7 +50,7 @@ protected AbstractGradientTexture(Size size, IGradient gradient) ///
/// The location to get the color from. /// The color at the specified location. - protected abstract Color GetColor(in Point point); + protected abstract Color GetColor(Point point); #endregion } \ No newline at end of file diff --git a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs index c60d9e4e..b9110e43 100644 --- a/RGB.NET.Presets/Textures/ConicalGradientTexture.cs +++ b/RGB.NET.Presets/Textures/ConicalGradientTexture.cs @@ -88,7 +88,7 @@ public ConicalGradientTexture(Size size, IGradient gradient, Point center, float #region Methods /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point point) { float angle = MathF.Atan2(point.Y - Center.Y, point.X - Center.X) - Origin; if (angle < 0) angle += PI2; diff --git a/RGB.NET.Presets/Textures/LinearGradientTexture.cs b/RGB.NET.Presets/Textures/LinearGradientTexture.cs index c5bc2f75..70db2ac5 100644 --- a/RGB.NET.Presets/Textures/LinearGradientTexture.cs +++ b/RGB.NET.Presets/Textures/LinearGradientTexture.cs @@ -71,7 +71,7 @@ public LinearGradientTexture(Size size, IGradient gradient, Point startPoint, Po #region Methods /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point 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 3f96dedd..3f299fca 100644 --- a/RGB.NET.Presets/Textures/RadialGradientTexture.cs +++ b/RGB.NET.Presets/Textures/RadialGradientTexture.cs @@ -69,7 +69,7 @@ private void CalculateReferenceDistance() } /// - protected override Color GetColor(in Point point) + protected override Color GetColor(Point point) { float distance = GradientHelper.CalculateDistance(point, Center); float offset = distance / _referenceDistance; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs index f9002c9b..a45fe64b 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageByteSampler.cs @@ -18,7 +18,7 @@ public sealed class AverageByteSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, Span pixelData) + public unsafe void Sample(SamplerInfo info, Span pixelData) { int count = info.Width * info.Height; if (count == 0) return; diff --git a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs index 9cdc37b1..dd1d0a43 100644 --- a/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs +++ b/RGB.NET.Presets/Textures/Sampler/AverageFloatSampler.cs @@ -12,7 +12,7 @@ public sealed class AverageFloatSampler : ISampler #region Methods /// - public unsafe void Sample(in SamplerInfo info, Span pixelData) + public unsafe void Sample(SamplerInfo info, Span pixelData) { int count = info.Width * info.Height; if (count == 0) return;