Skip to content

Commit

Permalink
fix: Re-add VectorExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 8, 2024
1 parent e3142de commit 3063947
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Uno.Foundation/Extensions/VectorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This class is a counterpart of VectorExtensions class in microsoft.windows.sdk.net.ref\WinRT.Runtime.dll
// Please do not remove it as third-parties may depend on it.

using System;
using System.Collections.Generic;
using System.Numerics;
using System.Text;
using Windows.Foundation;

namespace System.Numerics;

public static class VectorExtensions
{
/// <summary>
/// Converts a <see cref="Vector2"/> to <see cref="Point"/>
/// </summary>
/// <param name="vector">The <see cref="Vector2"/> to convert</param>
/// <returns>A <see cref="Point"/></returns>
public static Point ToPoint(this Vector2 vector) => new Point(vector.X, vector.Y);

/// <summary>
/// Converts a <see cref="Vector2"/> to <see cref="Size"/>
/// </summary>
/// <param name="vector">The <see cref="Vector2"/> to convert</param>
/// <returns>A <see cref="Size"/></returns>
public static Size ToSize(this Vector2 vector) => new Size(vector.X, vector.Y);

/// <summary>
/// Converts a <see cref="Point"/> to <see cref="Vector2"/>
/// </summary>
/// <param name="point">The <see cref="Point"/> to Convert</param>
/// <returns>A <see cref="Vector2"/></returns>
public static Vector2 ToVector2(this Point point) => new Vector2((float)point.X, (float)point.Y);

/// <summary>
/// Converts a <see cref="Size"/> to <see cref="Vector2"/>
/// </summary>
/// <param name="point">The <see cref="Size"/> to Convert</param>
/// <returns>A <see cref="Vector2"/></returns>
public static Vector2 ToVector2(this Size size) => new Vector2((float)size.Width, (float)size.Height);
}

0 comments on commit 3063947

Please sign in to comment.