Browse Source

[SL.Core] Fixed all stylecop warnings.

pull/1087/head
Dirk Lemstra 9 years ago
parent
commit
f58afef9ef
  1. 19
      src/SixLabors.Core/HashHelpers.cs
  2. 6
      src/SixLabors.Core/MathF.cs
  3. 4
      src/SixLabors.Core/Primitives/Matrix3x2Extensions.cs
  4. 38
      src/SixLabors.Core/Primitives/Point.cs
  5. 32
      src/SixLabors.Core/Primitives/PointF.cs
  6. 36
      src/SixLabors.Core/Primitives/Rectangle.cs
  7. 36
      src/SixLabors.Core/Primitives/RectangleF.cs
  8. 72
      src/SixLabors.Core/Primitives/Size.cs
  9. 64
      src/SixLabors.Core/Primitives/SizeF.cs

19
src/SixLabors.Core/HashHelpers.cs

@ -1,14 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
// <copyright file="HashHelpers.cs" company="Six Labors">
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace SixLabors
{
// lifted from coreFX repo
/// <summary>
/// Lifted from coreFX repo
/// </summary>
internal static class HashHelpers
{
public static readonly int RandomSeed = Guid.NewGuid().GetHashCode();
/// <summary>
/// Combines the two specified hash codes.
/// </summary>
/// <param name="h1">Hash code one</param>
/// <param name="h2">Hash code two</param>
/// <returns>Returns a hash code for the two specified has codes.</returns>
public static int Combine(int h1, int h2)
{
unchecked

6
src/SixLabors.Core/MathF.cs

@ -3,11 +3,11 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.Runtime.CompilerServices;
namespace SixLabors
{
using System;
using System.Runtime.CompilerServices;
/// <summary>
/// Provides single-precision floating point constants and static methods for trigonometric, logarithmic, and other common mathematical functions.
/// </summary>

4
src/SixLabors.Core/Primitives/Matrix3x2Extensions.cs

@ -3,10 +3,10 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System.Numerics;
namespace SixLabors.Primitives
{
using System.Numerics;
/// <summary>
/// Extension methods for the <see cref="Matrix3x2"/> struct.
/// </summary>

38
src/SixLabors.Core/Primitives/Point.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an ordered pair of integer x- and y-coordinates that defines a point in
/// a two-dimensional plane.
@ -182,7 +182,7 @@ namespace SixLabors.Primitives
/// Translates a <see cref="Point"/> by the negative of a given value
/// </summary>
/// <param name="point">The point on the left hand of the operand.</param>
/// <param name="size">The size on the right hand of the operand.</param>
/// <param name="value">The value on the right hand of the operand.</param>
/// <returns>The <see cref="Point"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Multiply(Point point, int value) => new Point(unchecked(point.X * value), unchecked(point.Y * value));
@ -212,6 +212,17 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Round(PointF point) => new Point(unchecked((int)MathF.Round(point.X)), unchecked((int)MathF.Round(point.Y)));
/// <summary>
/// Transforms a point by the given matrix.
/// </summary>
/// <param name="position">The source point.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed point.</returns>
public static PointF Transform(Point position, Matrix3x2 matrix)
{
return Vector2.Transform(position, matrix);
}
/// <summary>
/// Converts a <see cref="PointF"/> to a <see cref="Point"/> by performing a truncate operation on all the coordinates.
/// </summary>
@ -235,7 +246,7 @@ namespace SixLabors.Primitives
/// <param name="rotation">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Rotate(Point point, System.Numerics.Matrix3x2 rotation) => 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.
@ -244,7 +255,7 @@ namespace SixLabors.Primitives
/// <param name="skew">Rotation matrix used</param>
/// <returns>The rotated <see cref="Point"/></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point Skew(Point point, System.Numerics.Matrix3x2 skew) => Round(Vector2.Transform(new Vector2(point.X, point.Y), skew));
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.
@ -289,16 +300,5 @@ namespace SixLabors.Primitives
private static short LowInt16(int n) => unchecked((short)(n & 0xffff));
private int GetHashCode(Point point) => HashHelpers.Combine(point.X.GetHashCode(), point.Y.GetHashCode());
/// <summary>
/// Transforms a point by the given matrix.
/// </summary>
/// <param name="position"> The source point</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static PointF Transform(Point position, Matrix3x2 matrix)
{
return Vector2.Transform(position, matrix);
}
}
}

32
src/SixLabors.Core/Primitives/PointF.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Represents an ordered pair of single precision floating point x- and y-coordinates that defines a point in
/// a two-dimensional plane.
@ -258,6 +258,17 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static PointF Skew(PointF point, Matrix3x2 skew) => Vector2.Transform(new Vector2(point.X, point.Y), skew);
/// <summary>
/// Transforms a point by the given matrix.
/// </summary>
/// <param name="position">The source point.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed point.</returns>
public static PointF Transform(PointF position, Matrix3x2 matrix)
{
return Vector2.Transform(position, matrix);
}
/// <summary>
/// Translates this <see cref="PointF"/> by the specified amount.
/// </summary>
@ -303,16 +314,5 @@ namespace SixLabors.Primitives
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
private int GetHashCode(PointF point) => HashHelpers.Combine(point.X.GetHashCode(), point.Y.GetHashCode());
/// <summary>
/// Transforms a point by the given matrix.
/// </summary>
/// <param name="position"> The source point</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static PointF Transform(PointF position, Matrix3x2 matrix)
{
return Vector2.Transform(position, matrix);
}
}
}

36
src/SixLabors.Core/Primitives/Rectangle.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Stores a set of four integers that represent the location and size of a rectangle.
/// </summary>
@ -276,6 +276,19 @@ namespace SixLabors.Primitives
}
}
/// <summary>
/// Transforms a rectangle by the given matrix.
/// </summary>
/// <param name="rectangle">The source rectangle.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed rectangle.</returns>
public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix)
{
PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix);
PointF topLeft = Point.Transform(rectangle.Location, matrix);
return new RectangleF(topLeft, new SizeF(bottomRight - topLeft));
}
/// <summary>
/// Converts a <see cref="RectangleF"/> to a <see cref="Rectangle"/> by performing a truncate operation on all the coordinates.
/// </summary>
@ -455,18 +468,5 @@ namespace SixLabors.Primitives
hashCode = HashHelpers.Combine(hashCode, rectangle.Height.GetHashCode());
return hashCode;
}
/// <summary>
/// Transforms a rectangle by the given matrix.
/// </summary>
/// <param name="rectangle">The source rectangle</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static RectangleF Transform(Rectangle rectangle, Matrix3x2 matrix)
{
PointF bottomRight = Point.Transform(new Point(rectangle.Right, rectangle.Bottom), matrix);
PointF topLeft = Point.Transform(rectangle.Location, matrix);
return new RectangleF(topLeft, new SizeF(bottomRight - topLeft));
}
}
}

36
src/SixLabors.Core/Primitives/RectangleF.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Stores a set of four single precision floating points that represent the location and size of a rectangle.
/// </summary>
@ -251,6 +251,19 @@ namespace SixLabors.Primitives
return r;
}
/// <summary>
/// Transforms a rectangle by the given matrix.
/// </summary>
/// <param name="rectangle">The source rectangle.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed rectangle.</returns>
public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix)
{
PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix);
PointF topLeft = PointF.Transform(rectangle.Location, matrix);
return new RectangleF(topLeft, new SizeF(bottomRight - topLeft));
}
/// <summary>
/// Creates a rectangle that represents the union between <paramref name="a"/> and <paramref name="b"/>.
/// </summary>
@ -388,18 +401,5 @@ namespace SixLabors.Primitives
hashCode = HashHelpers.Combine(hashCode, rectangle.Height.GetHashCode());
return hashCode;
}
/// <summary>
/// Transforms a rectangle by the given matrix.
/// </summary>
/// <param name="rectangle">The source rectangle</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static RectangleF Transform(RectangleF rectangle, Matrix3x2 matrix)
{
PointF bottomRight = PointF.Transform(new PointF(rectangle.Right, rectangle.Bottom), matrix);
PointF topLeft = PointF.Transform(rectangle.Location, matrix);
return new RectangleF(topLeft, new SizeF(bottomRight - topLeft));
}
}
}

72
src/SixLabors.Core/Primitives/Size.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Stores an ordered pair of integers, which specify a height and width.
/// </summary>
@ -216,24 +216,6 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Size Subtract(Size left, Size right) => new Size(unchecked(left.Width - right.Width), unchecked(left.Height - right.Height));
/// <summary>
/// Multiplies <see cref="Size"/> by an <see cref="int"/> producing <see cref="Size"/>.
/// </summary>
/// <param name="size">Multiplicand of type <see cref="Size"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref='int'>.</param>
/// <returns>Product of type <see cref="Size"/>.</returns>
private static Size Multiply(Size size, int multiplier) =>
new Size(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier));
/// <summary>
/// Multiplies <see cref="Size"/> by a <see cref="float"/> producing <see cref="SizeF"/>.
/// </summary>
/// <param name="size">Multiplicand of type <see cref="Size"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref="float"/>.</param>
/// <returns>Product of type SizeF.</returns>
private static SizeF Multiply(Size size, float multiplier) =>
new SizeF(size.Width * multiplier, size.Height * multiplier);
/// <summary>
/// Converts a <see cref="SizeF"/> to a <see cref="Size"/> by performing a ceiling operation on all the dimensions.
/// </summary>
@ -250,6 +232,19 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Size Round(SizeF size) => new Size(unchecked((int)MathF.Round(size.Width)), unchecked((int)MathF.Round(size.Height)));
/// <summary>
/// Transforms a size by the given matrix.
/// </summary>
/// <param name="size">The source size</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed size.</returns>
public static SizeF Transform(Size size, Matrix3x2 matrix)
{
var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix);
return new SizeF(v.X, v.Y);
}
/// <summary>
/// Converts a <see cref="SizeF"/> to a <see cref="Size"/> by performing a round operation on all the dimensions.
/// </summary>
@ -274,6 +269,24 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Size other) => this.Width == other.Width && this.Height == other.Height;
/// <summary>
/// Multiplies <see cref="Size"/> by an <see cref="int"/> producing <see cref="Size"/>.
/// </summary>
/// <param name="size">Multiplicand of type <see cref="Size"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref="int"/>.</param>
/// <returns>Product of type <see cref="Size"/>.</returns>
private static Size Multiply(Size size, int multiplier) =>
new Size(unchecked(size.Width * multiplier), unchecked(size.Height * multiplier));
/// <summary>
/// Multiplies <see cref="Size"/> by a <see cref="float"/> producing <see cref="SizeF"/>.
/// </summary>
/// <param name="size">Multiplicand of type <see cref="Size"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref="float"/>.</param>
/// <returns>Product of type SizeF.</returns>
private static SizeF Multiply(Size size, float multiplier) =>
new SizeF(size.Width * multiplier, size.Height * multiplier);
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
@ -284,18 +297,5 @@ namespace SixLabors.Primitives
/// A 32-bit signed integer that is the hash code for this instance.
/// </returns>
private int GetHashCode(Size size) => HashHelpers.Combine(size.Width.GetHashCode(), size.Height.GetHashCode());
/// <summary>
/// Transforms a size by the given matrix.
/// </summary>
/// <param name="size">The source size</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static SizeF Transform(Size size, Matrix3x2 matrix)
{
var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix);
return new SizeF(v.X, v.Y);
}
}
}

64
src/SixLabors.Core/Primitives/SizeF.cs

@ -3,13 +3,13 @@
// Licensed under the Apache License, Version 2.0.
// </copyright>
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.Primitives
{
using System;
using System.ComponentModel;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Stores an ordered pair of single precision floating points, which specify a height and width.
/// </summary>
@ -72,6 +72,16 @@ namespace SixLabors.Primitives
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => this.Equals(Empty);
/// <summary>
/// Creates a <see cref="Vector2"/> with the coordinates of the specified <see cref="PointF"/>.
/// </summary>
/// <param name="point">The point.</param>
/// <returns>
/// The <see cref="Vector2"/>.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2(SizeF point) => new Vector2(point.Width, point.Height);
/// <summary>
/// Creates a <see cref="Size"/> with the dimensions of the specified <see cref="SizeF"/> by truncating each of the dimensions.
/// </summary>
@ -177,13 +187,17 @@ namespace SixLabors.Primitives
public static SizeF Subtract(SizeF left, SizeF right) => new SizeF(left.Width - right.Width, left.Height - right.Height);
/// <summary>
/// Multiplies <see cref="SizeF"/> by a <see cref="float"/> producing <see cref="SizeF"/>.
/// Transforms a size by the given matrix.
/// </summary>
/// <param name="size">Multiplicand of type <see cref="SizeF"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref="float"/>.</param>
/// <returns>Product of type SizeF.</returns>
private static SizeF Multiply(SizeF size, float multiplier) =>
new SizeF(size.Width * multiplier, size.Height * multiplier);
/// <param name="size">The source size.</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns>A transformed size.</returns>
public static SizeF Transform(SizeF size, Matrix3x2 matrix)
{
var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix);
return new SizeF(v.X, v.Y);
}
/// <inheritdoc/>
public override int GetHashCode()
@ -204,29 +218,15 @@ namespace SixLabors.Primitives
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(SizeF other) => this.Width.Equals(other.Width) && this.Height.Equals(other.Height);
private int GetHashCode(SizeF size) => HashHelpers.Combine(size.Width.GetHashCode(), size.Height.GetHashCode());
/// <summary>
/// Creates a <see cref="Vector2"/> with the coordinates of the specified <see cref="PointF"/>.
/// </summary>
/// <param name="point">The point.</param>
/// <returns>
/// The <see cref="Vector2"/>.
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector2(SizeF point) => new Vector2(point.Width, point.Height);
/// <summary>
/// Transforms a size by the given matrix.
/// Multiplies <see cref="SizeF"/> by a <see cref="float"/> producing <see cref="SizeF"/>.
/// </summary>
/// <param name="size">The source size</param>
/// <param name="matrix">The transformation matrix.</param>
/// <returns></returns>
public static SizeF Transform(SizeF size, Matrix3x2 matrix)
{
var v = Vector2.Transform(new Vector2(size.Width, size.Height), matrix);
/// <param name="size">Multiplicand of type <see cref="SizeF"/>.</param>
/// <param name="multiplier">Multiplier of type <see cref="float"/>.</param>
/// <returns>Product of type SizeF.</returns>
private static SizeF Multiply(SizeF size, float multiplier) =>
new SizeF(size.Width * multiplier, size.Height * multiplier);
return new SizeF(v.X, v.Y);
}
private int GetHashCode(SizeF size) => HashHelpers.Combine(size.Width.GetHashCode(), size.Height.GetHashCode());
}
}
Loading…
Cancel
Save