Add PointF.ToVector2 for .NET < 6

This commit is contained in:
Oliver Booth 2022-06-01 19:41:13 +01:00
parent 66a85d4f80
commit d91a3d2a8c
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 16 additions and 0 deletions

View File

@ -8,6 +8,7 @@
- X10D: Added `Point.ToSizeF()`
- X10D: Added `Point.ToVector2()`
- X10D: Added `PointF.ToSizeF()`
- X10D: Added `PointF.ToVector2()` for .NET < 6
- X10D: Added `RoundUpToPowerOf2()` for built-in integer types
- X10D: Added `Size.ToPoint()`
- X10D: Added `Size.ToPointF()`

View File

@ -1,5 +1,6 @@
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace X10D.Drawing;
@ -24,4 +25,18 @@ public static class PointFExtensions
{
return new SizeF(point.X, point.Y);
}
#if !NET6_0_OR_GREATER
/// <summary>
/// Converts the current <see cref="PointF" /> to a <see cref="Vector2" />.
/// </summary>
/// <param name="point">The point to convert.</param>
/// <returns>The resulting <see cref="Vector2" />.</returns>
[Pure]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector2 ToVector2(this PointF point)
{
return new Vector2(point.X, point.Y);
}
#endif
}