Extension methods refactored

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-11 01:46:34 +02:00
1 親 ef6f153f38
コミット 73c8b2d3e6
4ファイル変更
+85 -64

検索条件に一致するファイルはありません

+27
ファイルの表示
@@ -0,0 +1,27 @@
using System.Diagnostics.Contracts;
using System.Numerics;
namespace Windows.Foundation
{
/// <summary>
/// A <see langword="class"/> with some extension methods for the <see cref="Point"/> type
/// </summary>
public static class PointExtensions
{
/// <summary>
/// Converts a <see cref="Point"/> value to a <see cref="Vector2"/>
/// </summary>
/// <param name="value">The input <see cref="Point"/> to convert</param>
/// <returns>A <see cref="Vector2"/> value representing the input <see cref="Point"/></returns>
[Pure]
public static Vector2 ToVector2(this in Point value) => new Vector2((float)value.X, (float)value.Y);
/// <summary>
/// Converts a <see cref="Vector2"/> value to a <see cref="Point"/>
/// </summary>
/// <param name="value">The input <see cref="Vector2"/> to convert</param>
/// <returns>A <see cref="Point"/> value representing the input <see cref="Vector2"/></returns>
[Pure]
public static Point ToPoint(this in Vector2 value) => new Point(value.X, value.Y);
}
}
+29
ファイルの表示
@@ -0,0 +1,29 @@
using System.Diagnostics.Contracts;
using System.Numerics;
namespace Windows.Foundation
{
/// <summary>
/// A <see langword="class"/> with some extension methods for the <see cref="Rect"/> type
/// </summary>
public static class RectExtensions
{
/// <summary>
/// Converts a <see cref="Rect"/> value to a <see cref="Vector2"/>
/// </summary>
/// <param name="value">The input <see cref="Rect"/> to convert</param>
/// <returns>A <see cref="Vector2"/> value representing the input <see cref="Rect"/></returns>
/// <remarks>The input <see cref="Rect"/> is read in the following order: <see cref="Rect.Left"/>, <see cref="Rect.Top"/>, <see cref="Rect.Right"/>, <see cref="Rect.Bottom"/></remarks>
[Pure]
public static Vector4 ToVector2(this in Rect value) => new Vector4((float)value.Left, (float)value.Top, (float)value.Right, (float)value.Bottom);
/// <summary>
/// Converts a <see cref="Vector2"/> value to a <see cref="Rect"/>
/// </summary>
/// <param name="value">The input <see cref="Vector2"/> to convert</param>
/// <returns>A <see cref="Rect"/> value representing the input <see cref="Vector2"/></returns>
/// <remarks>The input <see cref="Vector4"/> is assigned in the following order: <see cref="Rect.Left"/>, <see cref="Rect.Top"/>, <see cref="Rect.Right"/>, <see cref="Rect.Bottom"/></remarks>
[Pure]
public static Rect ToPoint(this in Vector4 value) => new Rect(value.X, value.Y, value.Z, value.W);
}
}
+29
ファイルの表示
@@ -0,0 +1,29 @@
using System.Diagnostics.Contracts;
using System.Numerics;
namespace Windows.Foundation
{
/// <summary>
/// A <see langword="class"/> with some extension methods for the <see cref="Size"/> type
/// </summary>
public static class SizeExtensions
{
/// <summary>
/// Converts a <see cref="Size"/> value to a <see cref="Vector2"/>
/// </summary>
/// <param name="value">The input <see cref="Size"/> to convert</param>
/// <returns>A <see cref="Vector2"/> value representing the input <see cref="Size"/></returns>
/// <remarks>The input <see cref="Size"/> is read in the following order: <see cref="Size.Width"/>, <see cref="Size.Height"/></remarks>
[Pure]
public static Vector2 ToVector2(this in Size value) => new Vector2((float)value.Width, (float)value.Height);
/// <summary>
/// Converts a <see cref="Vector2"/> value to a <see cref="Size"/>
/// </summary>
/// <param name="value">The input <see cref="Vector2"/> to convert</param>
/// <returns>A <see cref="Point"/> value representing the input <see cref="Vector2"/></returns>
/// <remarks>The input <see cref="Size"/> is assigned in the following order: <see cref="Size.Width"/>, <see cref="Size.Height"/></remarks>
[Pure]
public static Size ToPoint(this in Vector2 value) => new Size(value.X, value.Y);
}
}
-64
ファイルの表示
@@ -1,64 +0,0 @@
using System.Numerics;
using Windows.Foundation;
namespace DirectX12GameEngine.Core
{
public static class PointExtensions
{
public static Vector2 ToVector2(this in Point value)
{
return new Vector2((float)value.X, (float)value.Y);
}
public static Point ToPoint(this in Vector2 value)
{
return new Point(value.X, value.Y);
}
public static System.Drawing.PointF ToPointF(this in Point value)
{
return new System.Drawing.PointF((float)value.X, (float)value.Y);
}
public static Point ToPoint(this in System.Drawing.PointF value)
{
return new Point(value.X, value.Y);
}
}
public static class RectangleExtensions
{
public static System.Drawing.RectangleF ToRectangleF(this in Rect value)
{
return new System.Drawing.RectangleF((float)value.X, (float)value.Y, (float)value.Width, (float)value.Height);
}
public static Rect ToRect(this in System.Drawing.RectangleF value)
{
return new Rect(value.X, value.Y, value.Width, value.Height);
}
}
public static class SizeExtensions
{
public static Vector2 ToVector2(this in Size value)
{
return new Vector2((float)value.Width, (float)value.Height);
}
public static Size ToSize(this in Vector2 value)
{
return new Size(value.X, value.Y);
}
public static System.Drawing.SizeF ToSizeF(this in Size value)
{
return new System.Drawing.SizeF((float)value.Width, (float)value.Height);
}
public static Size ToSize(this in System.Drawing.SizeF value)
{
return new Size(value.Width, value.Height);
}
}
}