diff --git a/src/ImageSharp/Numerics/Point.cs b/src/ImageSharp/Numerics/Point.cs
index 7c607885f5..4d43a83af2 100644
--- a/src/ImageSharp/Numerics/Point.cs
+++ b/src/ImageSharp/Numerics/Point.cs
@@ -79,30 +79,21 @@ namespace ImageSharp
///
/// The point
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator PointF(Point point)
- {
- return new PointF(point.X, point.Y);
- }
+ public static implicit operator PointF(Point point) => new PointF(point.X, point.Y);
///
/// Creates a with the coordinates of the specified .
///
/// The point
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator Vector2(Point point)
- {
- return new Vector2(point.X, point.Y);
- }
+ public static implicit operator Vector2(Point point) => new Vector2(point.X, point.Y);
///
/// Creates a with the coordinates of the specified .
///
/// The point
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static explicit operator Size(Point point)
- {
- return new Size(point.X, point.Y);
- }
+ public static explicit operator Size(Point point) => new Size(point.X, point.Y);
///
/// Translates a by a given .
@@ -113,10 +104,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point operator +(Point point, Size size)
- {
- return Add(point, size);
- }
+ public static Point operator +(Point point, Size size) => Add(point, size);
///
/// Translates a by the negative of a given .
@@ -125,10 +113,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point operator -(Point point, Size size)
- {
- return Subtract(point, size);
- }
+ public static Point operator -(Point point, Size size) => Subtract(point, size);
///
/// Compares two objects for equality.
@@ -139,10 +124,7 @@ namespace ImageSharp
/// True if the current left is equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(Point left, Point right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(Point left, Point right) => left.Equals(right);
///
/// Compares two objects for inequality.
@@ -153,10 +135,7 @@ namespace ImageSharp
/// True if the current left is unequal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(Point left, Point right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(Point left, Point right) => !left.Equals(right);
///
/// Translates a by the negative of a given .
@@ -165,10 +144,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Add(Point point, Size size)
- {
- return new Point(point.X + size.Width, point.Y + size.Height);
- }
+ public static Point Add(Point point, Size size) => new Point(unchecked(point.X + size.Width), unchecked(point.Y + size.Height));
///
/// Translates a by the negative of a given .
@@ -177,10 +153,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Subtract(Point point, Size size)
- {
- return new Point(point.X - size.Width, point.Y - size.Height);
- }
+ public static Point Subtract(Point point, Size size) => new Point(unchecked(point.X - size.Width), unchecked(point.Y - size.Height));
///
/// Converts a to a by performing a ceiling operation on all the coordinates.
@@ -188,10 +161,7 @@ namespace ImageSharp
/// The point
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Ceiling(PointF point)
- {
- return new Point((int)MathF.Ceiling(point.X), (int)MathF.Ceiling(point.Y));
- }
+ public static Point Ceiling(PointF point) => new Point(unchecked((int)MathF.Ceiling(point.X)), unchecked((int)MathF.Ceiling(point.Y)));
///
/// Converts a to a by performing a round operation on all the coordinates.
@@ -199,10 +169,15 @@ namespace ImageSharp
/// The point
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Round(PointF point)
- {
- return new Point((int)MathF.Round(point.X), (int)MathF.Round(point.Y));
- }
+ public static Point Round(PointF point) => new Point(unchecked((int)MathF.Round(point.X)), unchecked((int)MathF.Round(point.Y)));
+
+ ///
+ /// Converts a to a by performing a truncate operation on all the coordinates.
+ ///
+ /// The point
+ /// The
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Point Truncate(PointF point) => new Point(unchecked((int)point.X), unchecked((int)point.Y));
///
/// Converts a to a by performing a round operation on all the coordinates.
@@ -210,10 +185,7 @@ namespace ImageSharp
/// The vector
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Round(Vector2 vector)
- {
- return new Point((int)MathF.Round(vector.X), (int)MathF.Round(vector.Y));
- }
+ public static Point Round(Vector2 vector) => new Point(unchecked((int)MathF.Round(vector.X)), unchecked((int)MathF.Round(vector.Y)));
///
/// Rotates a point around the given rotation matrix.
@@ -222,10 +194,7 @@ namespace ImageSharp
/// Rotation matrix used
/// The rotated
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Rotate(Point point, Matrix3x2 rotation)
- {
- return Round(Vector2.Transform(new Vector2(point.X, point.Y), rotation));
- }
+ public static Point Rotate(Point point, Matrix3x2 rotation) => Round(Vector2.Transform(new Vector2(point.X, point.Y), rotation));
///
/// Skews a point using the given skew matrix.
@@ -234,19 +203,7 @@ namespace ImageSharp
/// Rotation matrix used
/// The rotated
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Point Skew(Point point, Matrix3x2 skew)
- {
- return Round(Vector2.Transform(new Vector2(point.X, point.Y), skew));
- }
-
- ///
- /// Gets a representation for this .
- ///
- /// A representation for this object.
- public Vector2 ToVector2()
- {
- return new Vector2(this.X, this.Y);
- }
+ public static Point Skew(Point point, Matrix3x2 skew) => Round(Vector2.Transform(new Vector2(point.X, point.Y), skew));
///
/// Translates this by the specified amount.
@@ -265,16 +222,10 @@ namespace ImageSharp
///
/// The used offset this .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void Offset(Point point)
- {
- this.Offset(point.X, point.Y);
- }
+ public void Offset(Point point) => this.Offset(point.X, point.Y);
///
- public override int GetHashCode()
- {
- return this.GetHashCode(this);
- }
+ public override int GetHashCode() => this.GetHashCode(this);
///
public override string ToString()
@@ -288,33 +239,16 @@ namespace ImageSharp
}
///
- public override bool Equals(object obj)
- {
- if (obj is Point)
- {
- return this.Equals((Point)obj);
- }
-
- return false;
- }
+ public override bool Equals(object obj) => obj is Point && this.Equals((Point)obj);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(Point other)
- {
- return this.X == other.X && this.Y == other.Y;
- }
+ public bool Equals(Point other) => this.X == other.X && this.Y == other.Y;
private static short HighInt16(int n) => unchecked((short)((n >> 16) & 0xffff));
private static short LowInt16(int n) => unchecked((short)(n & 0xffff));
- private int GetHashCode(Point point)
- {
- unchecked
- {
- return point.X ^ point.Y;
- }
- }
+ private int GetHashCode(Point point) => point.X ^ point.Y;
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Numerics/PointF.cs b/src/ImageSharp/Numerics/PointF.cs
index 1b76badb68..cbe5c7f48b 100644
--- a/src/ImageSharp/Numerics/PointF.cs
+++ b/src/ImageSharp/Numerics/PointF.cs
@@ -71,10 +71,7 @@ namespace ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator PointF(Vector2 vector)
- {
- return new PointF(vector.X, vector.Y);
- }
+ public static implicit operator PointF(Vector2 vector) => new PointF(vector.X, vector.Y);
///
/// Creates a with the coordinates of the specified .
@@ -84,10 +81,7 @@ namespace ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator Vector2(PointF point)
- {
- return new Vector2(point.X, point.Y);
- }
+ public static implicit operator Vector2(PointF point) => new Vector2(point.X, point.Y);
///
/// Creates a with the coordinates of the specified by truncating each of the coordinates.
@@ -97,10 +91,7 @@ namespace ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static explicit operator Point(PointF point)
- {
- return new Point(unchecked((int)MathF.Round(point.X)), unchecked((int)MathF.Round(point.Y)));
- }
+ public static explicit operator Point(PointF point) => Point.Truncate(point);
///
/// Translates a by a given .
@@ -111,10 +102,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF operator +(PointF point, SizeF size)
- {
- return Add(point, size);
- }
+ public static PointF operator +(PointF point, SizeF size) => Add(point, size);
///
/// Translates a by the negative of a given .
@@ -123,10 +111,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF operator -(PointF point, SizeF size)
- {
- return Subtract(point, size);
- }
+ public static PointF operator -(PointF point, SizeF size) => Subtract(point, size);
///
/// Compares two objects for equality.
@@ -141,10 +126,7 @@ namespace ImageSharp
/// True if the current left is equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(PointF left, PointF right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(PointF left, PointF right) => left.Equals(right);
///
/// Compares two objects for inequality.
@@ -159,10 +141,7 @@ namespace ImageSharp
/// True if the current left is unequal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(PointF left, PointF right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(PointF left, PointF right) => !left.Equals(right);
///
/// Translates a by the negative of a given .
@@ -171,10 +150,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF Add(PointF point, SizeF size)
- {
- return new PointF(point.X + size.Width, point.Y + size.Height);
- }
+ public static PointF Add(PointF point, SizeF size) => new PointF(point.X + size.Width, point.Y + size.Height);
///
/// Translates a by the negative of a given .
@@ -183,10 +159,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF Subtract(PointF point, SizeF size)
- {
- return new PointF(point.X - size.Width, point.Y - size.Height);
- }
+ public static PointF Subtract(PointF point, SizeF size) => new PointF(point.X - size.Width, point.Y - size.Height);
///
/// Rotates a point around the given rotation matrix.
@@ -195,10 +168,7 @@ namespace ImageSharp
/// Rotation matrix used
/// The rotated
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF Rotate(PointF point, Matrix3x2 rotation)
- {
- return Vector2.Transform(new Vector2(point.X, point.Y), rotation);
- }
+ public static PointF Rotate(PointF point, Matrix3x2 rotation) => Vector2.Transform(new Vector2(point.X, point.Y), rotation);
///
/// Skews a point using the given skew matrix.
@@ -207,10 +177,7 @@ namespace ImageSharp
/// Rotation matrix used
/// The rotated
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static PointF Skew(PointF point, Matrix3x2 skew)
- {
- return Vector2.Transform(new Vector2(point.X, point.Y), skew);
- }
+ public static PointF Skew(PointF point, Matrix3x2 skew) => Vector2.Transform(new Vector2(point.X, point.Y), skew);
///
/// Translates this by the specified amount.
@@ -229,16 +196,10 @@ namespace ImageSharp
///
/// The used offset this .
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void Offset(PointF point)
- {
- this.Offset(point.X, point.Y);
- }
+ public void Offset(PointF point) => this.Offset(point.X, point.Y);
///
- public override int GetHashCode()
- {
- return this.GetHashCode(this);
- }
+ public override int GetHashCode() => this.GetHashCode(this);
///
public override string ToString()
@@ -252,22 +213,11 @@ namespace ImageSharp
}
///
- public override bool Equals(object obj)
- {
- if (obj is PointF)
- {
- return this.Equals((PointF)obj);
- }
-
- return false;
- }
+ public override bool Equals(object obj) => obj is PointF && this.Equals((PointF)obj);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(PointF other)
- {
- return this.X.Equals(other.X) && this.Y.Equals(other.Y);
- }
+ public bool Equals(PointF other) => this.X.Equals(other.X) && this.Y.Equals(other.Y);
///
/// Returns the hash code for this instance.
@@ -278,12 +228,6 @@ namespace ImageSharp
///
/// A 32-bit signed integer that is the hash code for this instance.
///
- private int GetHashCode(PointF point)
- {
- unchecked
- {
- return point.X.GetHashCode() ^ point.Y.GetHashCode();
- }
- }
+ private int GetHashCode(PointF point) => point.X.GetHashCode() ^ point.Y.GetHashCode();
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Numerics/Size.cs b/src/ImageSharp/Numerics/Size.cs
index c462473076..79ee1ddead 100644
--- a/src/ImageSharp/Numerics/Size.cs
+++ b/src/ImageSharp/Numerics/Size.cs
@@ -87,20 +87,14 @@ namespace ImageSharp
///
/// The point
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static implicit operator SizeF(Size size)
- {
- return new SizeF(size.Width, size.Height);
- }
+ public static implicit operator SizeF(Size size) => new SizeF(size.Width, size.Height);
///
/// Converts the given into a .
///
/// The size
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static explicit operator Point(Size size)
- {
- return new Point(size.Width, size.Height);
- }
+ public static explicit operator Point(Size size) => new Point(size.Width, size.Height);
///
/// Computes the sum of adding two sizes.
@@ -111,10 +105,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size operator +(Size left, Size right)
- {
- return Add(left, right);
- }
+ public static Size operator +(Size left, Size right) => Add(left, right);
///
/// Computes the difference left by subtracting one size from another.
@@ -125,10 +116,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size operator -(Size left, Size right)
- {
- return Subtract(left, right);
- }
+ public static Size operator -(Size left, Size right) => Subtract(left, right);
///
/// Compares two objects for equality.
@@ -143,10 +131,7 @@ namespace ImageSharp
/// True if the current left is equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(Size left, Size right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(Size left, Size right) => left.Equals(right);
///
/// Compares two objects for inequality.
@@ -161,10 +146,7 @@ namespace ImageSharp
/// True if the current left is unequal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(Size left, Size right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(Size left, Size right) => !left.Equals(right);
///
/// Performs vector addition of two objects.
@@ -173,10 +155,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size Add(Size left, Size right)
- {
- return new Size(left.Width + right.Width, left.Height + right.Height);
- }
+ public static Size Add(Size left, Size right) => new Size(unchecked(left.Width + right.Width), unchecked(left.Height + right.Height));
///
/// Contracts a by another
@@ -185,10 +164,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size Subtract(Size left, Size right)
- {
- return new Size(left.Width - right.Width, left.Height - right.Height);
- }
+ public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height));
///
/// Converts a to a by performing a ceiling operation on all the dimensions.
@@ -196,10 +172,7 @@ namespace ImageSharp
/// The size
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size Ceiling(SizeF size)
- {
- return new Size((int)MathF.Ceiling(size.Width), (int)MathF.Ceiling(size.Height));
- }
+ public static Size Ceiling(SizeF size) => new Size(unchecked((int)MathF.Ceiling(size.Width)), unchecked((int)MathF.Ceiling(size.Height)));
///
/// Converts a to a by performing a round operation on all the dimensions.
@@ -207,16 +180,18 @@ namespace ImageSharp
/// The size
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Size Round(SizeF size)
- {
- return new Size((int)MathF.Round(size.Width), (int)MathF.Round(size.Height));
- }
+ public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height)));
+
+ ///
+ /// Converts a to a by performing a round operation on all the dimensions.
+ ///
+ /// The size
+ /// The
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height));
///
- public override int GetHashCode()
- {
- return this.GetHashCode(this);
- }
+ public override int GetHashCode() => this.GetHashCode(this);
///
public override string ToString()
@@ -230,22 +205,11 @@ namespace ImageSharp
}
///
- public override bool Equals(object obj)
- {
- if (obj is Size)
- {
- return this.Equals((Size)obj);
- }
-
- return false;
- }
+ public override bool Equals(object obj) => obj is Size && this.Equals((Size)obj);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(Size other)
- {
- return this.Width == other.Width && this.Height == other.Height;
- }
+ public bool Equals(Size other) => this.Width == other.Width && this.Height == other.Height;
///
/// Returns the hash code for this instance.
@@ -256,12 +220,6 @@ namespace ImageSharp
///
/// A 32-bit signed integer that is the hash code for this instance.
///
- private int GetHashCode(Size size)
- {
- unchecked
- {
- return size.Width ^ size.Height;
- }
- }
+ private int GetHashCode(Size size) => size.Width ^ size.Height;
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Numerics/SizeF.cs b/src/ImageSharp/Numerics/SizeF.cs
index f6b852cfa2..78078fd01f 100644
--- a/src/ImageSharp/Numerics/SizeF.cs
+++ b/src/ImageSharp/Numerics/SizeF.cs
@@ -79,20 +79,14 @@ namespace ImageSharp
/// The .
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static explicit operator Size(SizeF size)
- {
- return new Size(unchecked((int)size.Width), unchecked((int)size.Height));
- }
+ public static explicit operator Size(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height));
///
/// Converts the given into a .
///
/// The size
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static explicit operator PointF(SizeF size)
- {
- return new PointF(size.Width, size.Height);
- }
+ public static explicit operator PointF(SizeF size) => new PointF(size.Width, size.Height);
///
/// Computes the sum of adding two sizes.
@@ -103,10 +97,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static SizeF operator +(SizeF left, SizeF right)
- {
- return Add(left, right);
- }
+ public static SizeF operator +(SizeF left, SizeF right) => Add(left, right);
///
/// Computes the difference left by subtracting one size from another.
@@ -117,10 +108,7 @@ namespace ImageSharp
/// The
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static SizeF operator -(SizeF left, SizeF right)
- {
- return Subtract(left, right);
- }
+ public static SizeF operator -(SizeF left, SizeF right) => Subtract(left, right);
///
/// Compares two objects for equality.
@@ -131,10 +119,7 @@ namespace ImageSharp
/// True if the current left is equal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator ==(SizeF left, SizeF right)
- {
- return left.Equals(right);
- }
+ public static bool operator ==(SizeF left, SizeF right) => left.Equals(right);
///
/// Compares two objects for inequality.
@@ -145,10 +130,7 @@ namespace ImageSharp
/// True if the current left is unequal to the parameter; otherwise, false.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static bool operator !=(SizeF left, SizeF right)
- {
- return !left.Equals(right);
- }
+ public static bool operator !=(SizeF left, SizeF right) => !left.Equals(right);
///
/// Performs vector addition of two objects.
@@ -157,10 +139,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static SizeF Add(SizeF left, SizeF right)
- {
- return new SizeF(left.Width + right.Width, left.Height + right.Height);
- }
+ public static SizeF Add(SizeF left, SizeF right) => new SizeF(left.Width + right.Width, left.Height + right.Height);
///
/// Contracts a by another
@@ -169,10 +148,7 @@ namespace ImageSharp
/// The size on the right hand of the operand.
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static SizeF Subtract(SizeF left, SizeF right)
- {
- return new SizeF(left.Width - right.Width, left.Height - right.Height);
- }
+ public static SizeF Subtract(SizeF left, SizeF right) => new SizeF(left.Width - right.Width, left.Height - right.Height);
///
public override int GetHashCode()
@@ -192,38 +168,12 @@ namespace ImageSharp
}
///
- public override bool Equals(object obj)
- {
- if (obj is SizeF)
- {
- return this.Equals((SizeF)obj);
- }
-
- return false;
- }
+ public override bool Equals(object obj) => obj is SizeF && this.Equals((SizeF)obj);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(SizeF other)
- {
- return this.Width.Equals(other.Width) && this.Height.Equals(other.Height);
- }
+ public bool Equals(SizeF other) => this.Width.Equals(other.Width) && this.Height.Equals(other.Height);
- ///
- /// Returns the hash code for this instance.
- ///
- ///
- /// The instance of to return the hash code for.
- ///
- ///
- /// A 32-bit signed integer that is the hash code for this instance.
- ///
- private int GetHashCode(SizeF size)
- {
- unchecked
- {
- return size.Width.GetHashCode() ^ size.Height.GetHashCode();
- }
- }
+ private int GetHashCode(SizeF size) => size.Width.GetHashCode() ^ size.Height.GetHashCode();
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
index 23fea94e93..4e4a36a380 100644
--- a/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
@@ -52,7 +52,7 @@ namespace ImageSharp.Processing.Processors
int startX = sourceRectangle.X;
int endX = sourceRectangle.Right;
TPixel glowColor = this.GlowColor;
- var centre = Rectangle.Center(sourceRectangle).ToVector2();
+ Vector2 centre = Rectangle.Center(sourceRectangle);
float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;
// Align start/end positions.
diff --git a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
index 4dfa41989b..23ba5afe0f 100644
--- a/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
@@ -58,7 +58,7 @@ namespace ImageSharp.Processing.Processors
int startX = sourceRectangle.X;
int endX = sourceRectangle.Right;
TPixel vignetteColor = this.VignetteColor;
- var centre = Rectangle.Center(sourceRectangle).ToVector2();
+ Vector2 centre = Rectangle.Center(sourceRectangle);
float rX = this.RadiusX > 0 ? MathF.Min(this.RadiusX, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;
float rY = this.RadiusY > 0 ? MathF.Min(this.RadiusY, sourceRectangle.Height * .5F) : sourceRectangle.Height * .5F;
float maxDistance = MathF.Sqrt((rX * rX) + (rY * rY));
diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
index 7608d30659..be4929d9a7 100644
--- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
+++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs
@@ -79,7 +79,7 @@ namespace ImageSharp.Benchmarks
int startX = sourceRectangle.X;
int endX = sourceRectangle.Right;
TPixel glowColor = this.GlowColor;
- Vector2 centre = Rectangle.Center(sourceRectangle).ToVector2();
+ Vector2 centre = Rectangle.Center(sourceRectangle);
float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;
// Align start/end positions.