Browse Source

Cleanup

af/merge-core
James Jackson-South 9 years ago
parent
commit
d4a10f9d3e
  1. 120
      src/ImageSharp/Numerics/Point.cs
  2. 88
      src/ImageSharp/Numerics/PointF.cs
  3. 88
      src/ImageSharp/Numerics/Size.cs
  4. 72
      src/ImageSharp/Numerics/SizeF.cs
  5. 2
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
  6. 2
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
  7. 2
      tests/ImageSharp.Benchmarks/Samplers/Glow.cs

120
src/ImageSharp/Numerics/Point.cs

@ -79,30 +79,21 @@ namespace ImageSharp
/// </summary>
/// <param name="point">The point</param>
[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);
/// <summary>
/// Creates a <see cref="Vector2"/> with the coordinates of the specified <see cref="Point"/>.
/// </summary>
/// <param name="point">The point</param>
[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);
/// <summary>
/// Creates a <see cref="Size"/> with the coordinates of the specified <see cref="Point"/>.
/// </summary>
/// <param name="point">The point</param>
[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);
/// <summary>
/// Translates a <see cref="Point"/> by a given <see cref="Size"/>.
@ -113,10 +104,7 @@ namespace ImageSharp
/// The <see cref="Point"/>
/// </returns>
[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);
/// <summary>
/// Translates a <see cref="Point"/> by the negative of a given <see cref="Size"/>.
@ -125,10 +113,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="Point"/></returns>
[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);
/// <summary>
/// Compares two <see cref="Point"/> objects for equality.
@ -139,10 +124,7 @@ namespace ImageSharp
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="Point"/> objects for inequality.
@ -153,10 +135,7 @@ namespace ImageSharp
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Translates a <see cref="Point"/> by the negative of a given <see cref="Size"/>.
@ -165,10 +144,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="Point"/></returns>
[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));
/// <summary>
/// Translates a <see cref="Point"/> by the negative of a given <see cref="Size"/>.
@ -177,10 +153,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="Point"/></returns>
[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));
/// <summary>
/// Converts a <see cref="PointF"/> to a <see cref="Point"/> by performing a ceiling operation on all the coordinates.
@ -188,10 +161,7 @@ namespace ImageSharp
/// <param name="point">The point</param>
/// <returns>The <see cref="Point"/></returns>
[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)));
/// <summary>
/// Converts a <see cref="PointF"/> to a <see cref="Point"/> by performing a round operation on all the coordinates.
@ -199,10 +169,15 @@ namespace ImageSharp
/// <param name="point">The point</param>
/// <returns>The <see cref="Point"/></returns>
[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)));
/// <summary>
/// Converts a <see cref="PointF"/> to a <see cref="Point"/> by performing a truncate operation on all the coordinates.
/// </summary>
/// <param name="point">The point</param>
/// <returns>The <see cref="Point"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Truncate(PointF point) => new Point(unchecked((int)point.X), unchecked((int)point.Y));
/// <summary>
/// Converts a <see cref="Vector2"/> to a <see cref="Point"/> by performing a round operation on all the coordinates.
@ -210,10 +185,7 @@ namespace ImageSharp
/// <param name="vector">The vector</param>
/// <returns>The <see cref="Point"/></returns>
[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)));
/// <summary>
/// Rotates a point around the given rotation matrix.
@ -222,10 +194,7 @@ namespace ImageSharp
/// <param name="rotation">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
[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));
/// <summary>
/// Skews a point using the given skew matrix.
@ -234,19 +203,7 @@ namespace ImageSharp
/// <param name="skew">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Skew(Point point, Matrix3x2 skew)
{
return Round(Vector2.Transform(new Vector2(point.X, point.Y), skew));
}
/// <summary>
/// Gets a <see cref="Vector2"/> representation for this <see cref="Point"/>.
/// </summary>
/// <returns>A <see cref="Vector2"/> representation for this object.</returns>
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));
/// <summary>
/// Translates this <see cref="Point"/> by the specified amount.
@ -265,16 +222,10 @@ namespace ImageSharp
/// </summary>
/// <param name="point">The <see cref="Point"/> used offset this <see cref="Point"/>.</param>
[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);
/// <inheritdoc/>
public override int GetHashCode()
{
return this.GetHashCode(this);
}
public override int GetHashCode() => this.GetHashCode(this);
/// <inheritdoc/>
public override string ToString()
@ -288,33 +239,16 @@ namespace ImageSharp
}
/// <inheritdoc/>
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);
/// <inheritdoc/>
[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;
}
}

88
src/ImageSharp/Numerics/PointF.cs

@ -71,10 +71,7 @@ namespace ImageSharp
/// The <see cref="Vector2"/>.
/// </returns>
[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);
/// <summary>
/// Creates a <see cref="Vector2"/> with the coordinates of the specified <see cref="PointF"/>.
@ -84,10 +81,7 @@ namespace ImageSharp
/// The <see cref="Vector2"/>.
/// </returns>
[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);
/// <summary>
/// Creates a <see cref="Point"/> with the coordinates of the specified <see cref="PointF"/> by truncating each of the coordinates.
@ -97,10 +91,7 @@ namespace ImageSharp
/// The <see cref="Point"/>.
/// </returns>
[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);
/// <summary>
/// Translates a <see cref="PointF"/> by a given <see cref="SizeF"/>.
@ -111,10 +102,7 @@ namespace ImageSharp
/// The <see cref="PointF"/>
/// </returns>
[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);
/// <summary>
/// Translates a <see cref="PointF"/> by the negative of a given <see cref="SizeF"/>.
@ -123,10 +111,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="PointF"/></returns>
[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);
/// <summary>
/// Compares two <see cref="PointF"/> objects for equality.
@ -141,10 +126,7 @@ namespace ImageSharp
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="PointF"/> objects for inequality.
@ -159,10 +141,7 @@ namespace ImageSharp
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Translates a <see cref="PointF"/> by the negative of a given <see cref="SizeF"/>.
@ -171,10 +150,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="PointF"/></returns>
[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);
/// <summary>
/// Translates a <see cref="PointF"/> by the negative of a given <see cref="SizeF"/>.
@ -183,10 +159,7 @@ namespace ImageSharp
/// <param name="size">The size on the right hand of the operand.</param>
/// <returns>The <see cref="PointF"/></returns>
[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);
/// <summary>
/// Rotates a point around the given rotation matrix.
@ -195,10 +168,7 @@ namespace ImageSharp
/// <param name="rotation">Rotation matrix used</param>
/// <returns>The rotated <see cref="PointF"/></returns>
[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);
/// <summary>
/// Skews a point using the given skew matrix.
@ -207,10 +177,7 @@ namespace ImageSharp
/// <param name="skew">Rotation matrix used</param>
/// <returns>The rotated <see cref="PointF"/></returns>
[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);
/// <summary>
/// Translates this <see cref="PointF"/> by the specified amount.
@ -229,16 +196,10 @@ namespace ImageSharp
/// </summary>
/// <param name="point">The <see cref="PointF"/> used offset this <see cref="PointF"/>.</param>
[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);
/// <inheritdoc/>
public override int GetHashCode()
{
return this.GetHashCode(this);
}
public override int GetHashCode() => this.GetHashCode(this);
/// <inheritdoc/>
public override string ToString()
@ -252,22 +213,11 @@ namespace ImageSharp
}
/// <inheritdoc/>
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);
/// <inheritdoc/>
[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);
/// <summary>
/// Returns the hash code for this instance.
@ -278,12 +228,6 @@ namespace ImageSharp
/// <returns>
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
private int GetHashCode(PointF point)
{
unchecked
{
return point.X.GetHashCode() ^ point.Y.GetHashCode();
}
}
private int GetHashCode(PointF point) => point.X.GetHashCode() ^ point.Y.GetHashCode();
}
}

88
src/ImageSharp/Numerics/Size.cs

@ -87,20 +87,14 @@ namespace ImageSharp
/// </summary>
/// <param name="size">The point</param>
[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);
/// <summary>
/// Converts the given <see cref="Size"/> into a <see cref="Point"/>.
/// </summary>
/// <param name="size">The size</param>
[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);
/// <summary>
/// Computes the sum of adding two sizes.
@ -111,10 +105,7 @@ namespace ImageSharp
/// The <see cref="Size"/>
/// </returns>
[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);
/// <summary>
/// Computes the difference left by subtracting one size from another.
@ -125,10 +116,7 @@ namespace ImageSharp
/// The <see cref="Size"/>
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="Size"/> objects for equality.
@ -143,10 +131,7 @@ namespace ImageSharp
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="Size"/> objects for inequality.
@ -161,10 +146,7 @@ namespace ImageSharp
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Performs vector addition of two <see cref="Size"/> objects.
@ -173,10 +155,7 @@ namespace ImageSharp
/// <param name="right">The size on the right hand of the operand.</param>
/// <returns>The <see cref="Size"/></returns>
[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));
/// <summary>
/// Contracts a <see cref="Size"/> by another <see cref="Size"/>
@ -185,10 +164,7 @@ namespace ImageSharp
/// <param name="right">The size on the right hand of the operand.</param>
/// <returns>The <see cref="Size"/></returns>
[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));
/// <summary>
/// Converts a <see cref="SizeF"/> to a <see cref="Size"/> by performing a ceiling operation on all the dimensions.
@ -196,10 +172,7 @@ namespace ImageSharp
/// <param name="size">The size</param>
/// <returns>The <see cref="Size"/></returns>
[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)));
/// <summary>
/// Converts a <see cref="SizeF"/> to a <see cref="Size"/> by performing a round operation on all the dimensions.
@ -207,16 +180,18 @@ namespace ImageSharp
/// <param name="size">The size</param>
/// <returns>The <see cref="Size"/></returns>
[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)));
/// <summary>
/// Converts a <see cref="SizeF"/> to a <see cref="Size"/> by performing a round operation on all the dimensions.
/// </summary>
/// <param name="size">The size</param>
/// <returns>The <see cref="Size"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Size Truncate(SizeF size) => new Size(unchecked((int)size.Width), unchecked((int)size.Height));
/// <inheritdoc/>
public override int GetHashCode()
{
return this.GetHashCode(this);
}
public override int GetHashCode() => this.GetHashCode(this);
/// <inheritdoc/>
public override string ToString()
@ -230,22 +205,11 @@ namespace ImageSharp
}
/// <inheritdoc/>
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);
/// <inheritdoc/>
[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;
/// <summary>
/// Returns the hash code for this instance.
@ -256,12 +220,6 @@ namespace ImageSharp
/// <returns>
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
private int GetHashCode(Size size)
{
unchecked
{
return size.Width ^ size.Height;
}
}
private int GetHashCode(Size size) => size.Width ^ size.Height;
}
}
}

72
src/ImageSharp/Numerics/SizeF.cs

@ -79,20 +79,14 @@ namespace ImageSharp
/// The <see cref="Size"/>.
/// </returns>
[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));
/// <summary>
/// Converts the given <see cref="SizeF"/> into a <see cref="PointF"/>.
/// </summary>
/// <param name="size">The size</param>
[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);
/// <summary>
/// Computes the sum of adding two sizes.
@ -103,10 +97,7 @@ namespace ImageSharp
/// The <see cref="SizeF"/>
/// </returns>
[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);
/// <summary>
/// Computes the difference left by subtracting one size from another.
@ -117,10 +108,7 @@ namespace ImageSharp
/// The <see cref="SizeF"/>
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="SizeF"/> objects for equality.
@ -131,10 +119,7 @@ namespace ImageSharp
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Compares two <see cref="SizeF"/> objects for inequality.
@ -145,10 +130,7 @@ namespace ImageSharp
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
[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);
/// <summary>
/// Performs vector addition of two <see cref="SizeF"/> objects.
@ -157,10 +139,7 @@ namespace ImageSharp
/// <param name="right">The size on the right hand of the operand.</param>
/// <returns>The <see cref="SizeF"/></returns>
[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);
/// <summary>
/// Contracts a <see cref="SizeF"/> by another <see cref="SizeF"/>
@ -169,10 +148,7 @@ namespace ImageSharp
/// <param name="right">The size on the right hand of the operand.</param>
/// <returns>The <see cref="SizeF"/></returns>
[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);
/// <inheritdoc/>
public override int GetHashCode()
@ -192,38 +168,12 @@ namespace ImageSharp
}
/// <inheritdoc/>
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);
/// <inheritdoc/>
[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);
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
/// <param name="size">
/// The instance of <see cref="SizeF"/> to return the hash code for.
/// </param>
/// <returns>
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
private int GetHashCode(SizeF size)
{
unchecked
{
return size.Width.GetHashCode() ^ size.Height.GetHashCode();
}
}
private int GetHashCode(SizeF size) => size.Width.GetHashCode() ^ size.Height.GetHashCode();
}
}

2
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.

2
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));

2
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.

Loading…
Cancel
Save