diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a42897..938238d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,15 +3,35 @@
## 3.2.0
### Added
- X10D: Added `MathUtility.InverseLerp(float, float, float)` and `MathUtility.InverseLerp(double, double, double)`
+- X10D: Added `Point.ToSize()`
+- X10D: Added `Point.ToSizeF()`
+- X10D: Added `Point.ToVector2()`
+- X10D: Added `PointF.ToSizeF()`
- X10D: Added `RoundUpToPowerOf2()` for built-in integer types
+- X10D: Added `Size.ToPoint()`
+- X10D: Added `Size.ToPointF()`
+- X10D: Added `Size.ToVector2()`
- X10D: Added `Vector2.Deconstruct()`
+- X10D: Added `Vector2.ToPointF()`
+- X10D: Added `Vector2.ToSizeF()`
- X10D: Added `Vector3.Deconstruct()`
- X10D: Added `Vector4.Deconstruct()`
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor()`
- X10D.Unity: Added `System.Drawing.Color.ToUnityColor32()`
- X10D.Unity: Added `Color.ToSystemDrawingColor()`
- X10D.Unity: Added `Color32.ToSystemDrawingColor()`
+- X10D.Unity: Added `Point.ToUnityVector2()`
+- X10D.Unity: Added `Point.ToUnityVector2Int()`
+- X10D.Unity: Added `PointF.ToUnityVector2()`
+- X10D.Unity: Added `Rect.ToSystemRectangleF()`
+- X10D.Unity: Added `Rectangle.ToUnityRect()`
+- X10D.Unity: Added `RectangleF.ToUnityRect()`
+- X10D.Unity: Added `Size.ToUnityVector2()`
+- X10D.Unity: Added `Size.ToUnityVector2Int()`
+- X10D.Unity: Added `SizeF.ToUnityVector2()`
- X10D.Unity: Added `Vector2.Deconstruct()`
+- X10D.Unity: Added `Vector2.ToSystemPointF()`
+- X10D.Unity: Added `Vector2.ToSystemSizeF()`
- X10D.Unity: Added `Vector3.Deconstruct()`
- X10D.Unity: Added `Vector4.Deconstruct()`
diff --git a/X10D.Tests/src/Drawing/PointFTests.cs b/X10D.Tests/src/Drawing/PointFTests.cs
new file mode 100644
index 0000000..577aa78
--- /dev/null
+++ b/X10D.Tests/src/Drawing/PointFTests.cs
@@ -0,0 +1,21 @@
+using System.Drawing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using X10D.Core;
+using X10D.Drawing;
+
+namespace X10D.Tests.Drawing;
+
+[TestClass]
+public class PointFTests
+{
+ [TestMethod]
+ public void ToSizeF_ShouldReturnSize_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new PointF(random.NextSingle(), random.NextSingle());
+ var size = point.ToSizeF();
+
+ Assert.AreEqual(point.X, size.Width, 1e-6f);
+ Assert.AreEqual(point.Y, size.Height, 1e-6f);
+ }
+}
diff --git a/X10D.Tests/src/Drawing/PointTests.cs b/X10D.Tests/src/Drawing/PointTests.cs
new file mode 100644
index 0000000..92adc0a
--- /dev/null
+++ b/X10D.Tests/src/Drawing/PointTests.cs
@@ -0,0 +1,42 @@
+using System.Drawing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using X10D.Drawing;
+
+namespace X10D.Tests.Drawing;
+
+[TestClass]
+public class PointTests
+{
+ [TestMethod]
+ public void ToSize_ShouldReturnSize_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Point(random.Next(), random.Next());
+ var size = point.ToSize();
+
+ Assert.AreEqual(point.X, size.Width);
+ Assert.AreEqual(point.Y, size.Height);
+ }
+
+ [TestMethod]
+ public void ToSizeF_ShouldReturnSize_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Point(random.Next(), random.Next());
+ var size = point.ToSizeF();
+
+ Assert.AreEqual(point.X, size.Width, 1e-6f);
+ Assert.AreEqual(point.Y, size.Height, 1e-6f);
+ }
+
+ [TestMethod]
+ public void ToVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Point(random.Next(), random.Next());
+ var size = point.ToVector2();
+
+ Assert.AreEqual(point.X, size.X, 1e-6f);
+ Assert.AreEqual(point.Y, size.Y, 1e-6f);
+ }
+}
diff --git a/X10D.Tests/src/Drawing/SizeTests.cs b/X10D.Tests/src/Drawing/SizeTests.cs
new file mode 100644
index 0000000..8dbd957
--- /dev/null
+++ b/X10D.Tests/src/Drawing/SizeTests.cs
@@ -0,0 +1,42 @@
+using System.Drawing;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using X10D.Drawing;
+
+namespace X10D.Tests.Drawing;
+
+[TestClass]
+public class SizeTests
+{
+ [TestMethod]
+ public void ToPoint_ShouldReturnPoint_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var size = new Size(random.Next(), random.Next());
+ var point = size.ToPoint();
+
+ Assert.AreEqual(size.Width, point.X);
+ Assert.AreEqual(size.Height, point.Y);
+ }
+
+ [TestMethod]
+ public void ToPointF_ShouldReturnPoint_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var size = new Size(random.Next(), random.Next());
+ var point = size.ToPointF();
+
+ Assert.AreEqual(size.Width, point.X, 1e-6f);
+ Assert.AreEqual(size.Height, point.Y, 1e-6f);
+ }
+
+ [TestMethod]
+ public void ToVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Size(random.Next(), random.Next());
+ var size = point.ToVector2();
+
+ Assert.AreEqual(point.Width, size.X, 1e-6f);
+ Assert.AreEqual(point.Height, size.Y, 1e-6f);
+ }
+}
diff --git a/X10D.Tests/src/Numerics/Vector2Tests.cs b/X10D.Tests/src/Numerics/Vector2Tests.cs
index a32d225..b20a300 100644
--- a/X10D.Tests/src/Numerics/Vector2Tests.cs
+++ b/X10D.Tests/src/Numerics/Vector2Tests.cs
@@ -1,5 +1,6 @@
using System.Numerics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using X10D.Core;
using X10D.Numerics;
namespace X10D.Tests.Numerics;
@@ -17,6 +18,28 @@ public class Vector2Tests
Assert.AreEqual(2, y);
}
+ [TestMethod]
+ public void ToPointF_ShouldReturnPoint_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var vector = new Vector2(random.NextSingle(), random.NextSingle());
+ var point = vector.ToPointF();
+
+ Assert.AreEqual(vector.X, point.X, 1e-6f);
+ Assert.AreEqual(vector.Y, point.Y, 1e-6f);
+ }
+
+ [TestMethod]
+ public void ToSizeF_ShouldReturnSize_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var vector = new Vector2(random.NextSingle(), random.NextSingle());
+ var size = vector.ToSizeF();
+
+ Assert.AreEqual(vector.X, size.Width);
+ Assert.AreEqual(vector.Y, size.Height);
+ }
+
[TestMethod]
public void WithX_ShouldReturnVectorWithNewX_GivenVector()
{
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs
new file mode 100644
index 0000000..83d70ea
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Core;
+using X10D.Unity.Drawing;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class PointFTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new PointF(random.NextSingle(), random.NextSingle());
+ var vector = point.ToUnityVector2();
+
+ Assert.AreEqual(point.X, vector.x, 1e-6f);
+ Assert.AreEqual(point.Y, vector.y, 1e-6f);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta
new file mode 100644
index 0000000..751b242
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointFTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: d90695756d1d4760aef2523486b1b41e
+timeCreated: 1653743243
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs
new file mode 100644
index 0000000..36b8554
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Unity.Drawing;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class PointTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Point(random.Next(), random.Next());
+ var vector = point.ToUnityVector2();
+
+ Assert.AreEqual(point.X, vector.x);
+ Assert.AreEqual(point.Y, vector.y);
+
+ yield break;
+ }
+
+ [UnityTest]
+ public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var point = new Point(random.Next(), random.Next());
+ var vector = point.ToUnityVector2Int();
+
+ Assert.AreEqual(point.X, vector.x);
+ Assert.AreEqual(point.Y, vector.y);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta
new file mode 100644
index 0000000..8a5fdf4
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/PointTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f465794fdc394d05a34229f34e5199e2
+timeCreated: 1653742987
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs
new file mode 100644
index 0000000..eb5a94d
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using NUnit.Framework;
+using UnityEngine;
+using UnityEngine.TestTools;
+using X10D.Core;
+using X10D.Unity.Drawing;
+using Random = System.Random;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class RectTests
+ {
+ [UnityTest]
+ public IEnumerator ToSystemRectangleF_ShouldReturnRectangleF_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var rect = new Rect(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
+ var rectangle = rect.ToSystemRectangleF();
+
+ Assert.AreEqual(rect.x, rectangle.X, 1e-6f);
+ Assert.AreEqual(rect.y, rectangle.Y, 1e-6f);
+ Assert.AreEqual(rect.width, rectangle.Width, 1e-6f);
+ Assert.AreEqual(rect.height, rectangle.Height, 1e-6f);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta
new file mode 100644
index 0000000..ee14568
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: bb1ec5372c354f06b39e03649b9307db
+timeCreated: 1653743583
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs
new file mode 100644
index 0000000..b49312c
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Core;
+using X10D.Unity.Drawing;
+using Random = System.Random;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class RectangleFTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var rectangle = new RectangleF(random.NextSingle(), random.NextSingle(), random.NextSingle(), random.NextSingle());
+ var rect = rectangle.ToUnityRect();
+
+ Assert.AreEqual(rectangle.X, rect.x, 1e-6f);
+ Assert.AreEqual(rectangle.Y, rect.y, 1e-6f);
+ Assert.AreEqual(rectangle.Width, rect.width, 1e-6f);
+ Assert.AreEqual(rectangle.Height, rect.height, 1e-6f);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta
new file mode 100644
index 0000000..8cec772
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleFTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: f38cbc892021405cad2b52de1f960a00
+timeCreated: 1653743640
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs
new file mode 100644
index 0000000..4a7eb2d
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs
@@ -0,0 +1,27 @@
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Unity.Drawing;
+using Random = System.Random;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class RectangleTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityRect_ShouldReturnRect_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var rectangle = new Rectangle(random.Next(), random.Next(), random.Next(), random.Next());
+ var rect = rectangle.ToUnityRect();
+
+ Assert.AreEqual(rectangle.X, rect.x);
+ Assert.AreEqual(rectangle.Y, rect.y);
+ Assert.AreEqual(rectangle.Width, rect.width);
+ Assert.AreEqual(rectangle.Height, rect.height);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta
new file mode 100644
index 0000000..2551e69
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/RectangleTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9c74177035d1452a8a7ca08c0a27124b
+timeCreated: 1653743677
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs
new file mode 100644
index 0000000..e677867
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Core;
+using X10D.Unity.Drawing;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class SizeFTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var size = new SizeF(random.NextSingle(), random.NextSingle());
+ var vector = size.ToUnityVector2();
+
+ Assert.AreEqual(size.Width, vector.x, 1e-6f);
+ Assert.AreEqual(size.Height, vector.y, 1e-6f);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta
new file mode 100644
index 0000000..ac99418
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeFTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: b93fe56510de4ddcb9354bde7f10c362
+timeCreated: 1653743377
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs
new file mode 100644
index 0000000..0832375
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections;
+using System.Drawing;
+using NUnit.Framework;
+using UnityEngine.TestTools;
+using X10D.Unity.Drawing;
+
+namespace X10D.Unity.Tests.Drawing
+{
+ public class SizeTests
+ {
+ [UnityTest]
+ public IEnumerator ToUnityVector2_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var size = new Size(random.Next(), random.Next());
+ var vector = size.ToUnityVector2();
+
+ Assert.AreEqual(size.Width, vector.x);
+ Assert.AreEqual(size.Height, vector.y);
+
+ yield break;
+ }
+
+ [UnityTest]
+ public IEnumerator ToUnityVector2Int_ShouldReturnVector_WithEquivalentMembers()
+ {
+ var random = new Random();
+ var size = new Size(random.Next(), random.Next());
+ var vector = size.ToUnityVector2Int();
+
+ Assert.AreEqual(size.Width, vector.x);
+ Assert.AreEqual(size.Height, vector.y);
+
+ yield break;
+ }
+ }
+}
diff --git a/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta
new file mode 100644
index 0000000..572e5f7
--- /dev/null
+++ b/X10D.Unity.Tests/Assets/Tests/Drawing/SizeTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: c748bfe02fce4b459df7ef2779c2a486
+timeCreated: 1653743400
\ No newline at end of file
diff --git a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs
index 3d13d40..860b593 100644
--- a/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs
+++ b/X10D.Unity.Tests/Assets/Tests/Numerics/Vector2Tests.cs
@@ -22,6 +22,38 @@ namespace X10D.Unity.Tests.Numerics
yield break;
}
+ [UnityTest]
+ public IEnumerator ToSystemPointF_ShouldReturnPoint_WithEquivalentMembers()
+ {
+ var random = new Random();
+ float x = random.NextSingle();
+ float y = random.NextSingle();
+
+ var vector = new Vector2(x, y);
+ var point = vector.ToSystemPointF();
+
+ Assert.AreEqual(vector.x, point.X, 1e-6f);
+ Assert.AreEqual(vector.y, point.Y, 1e-6f);
+
+ yield break;
+ }
+
+ [UnityTest]
+ public IEnumerator ToSystemSizeF_ShouldReturnPoint_WithEquivalentMembers()
+ {
+ var random = new Random();
+ float x = random.NextSingle();
+ float y = random.NextSingle();
+
+ var vector = new Vector2(x, y);
+ var point = vector.ToSystemSizeF();
+
+ Assert.AreEqual(vector.x, point.Width, 1e-6f);
+ Assert.AreEqual(vector.y, point.Height, 1e-6f);
+
+ yield break;
+ }
+
[UnityTest]
public IEnumerator ToSystemVector_ShouldReturnVector_WithEqualComponents()
{
diff --git a/X10D.Unity/src/Drawing/PointExtensions.cs b/X10D.Unity/src/Drawing/PointExtensions.cs
new file mode 100644
index 0000000..f219272
--- /dev/null
+++ b/X10D.Unity/src/Drawing/PointExtensions.cs
@@ -0,0 +1,36 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class PointExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 ToUnityVector2(this Point point)
+ {
+ return new Vector2(point.X, point.Y);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2Int ToUnityVector2Int(this Point value)
+ {
+ return new Vector2Int(value.X, value.Y);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/PointFExtensions.cs b/X10D.Unity/src/Drawing/PointFExtensions.cs
new file mode 100644
index 0000000..fa936ce
--- /dev/null
+++ b/X10D.Unity/src/Drawing/PointFExtensions.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class PointFExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 ToUnityVector2(this PointF point)
+ {
+ return new Vector2(point.X, point.Y);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/RectExtensions.cs b/X10D.Unity/src/Drawing/RectExtensions.cs
new file mode 100644
index 0000000..8fd6dac
--- /dev/null
+++ b/X10D.Unity/src/Drawing/RectExtensions.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class RectExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The rectangle to convert.
+ /// The converted rectangle.
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static RectangleF ToSystemRectangleF(this Rect rectangle)
+ {
+ return new RectangleF(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/RectangleExtensions.cs b/X10D.Unity/src/Drawing/RectangleExtensions.cs
new file mode 100644
index 0000000..371ccae
--- /dev/null
+++ b/X10D.Unity/src/Drawing/RectangleExtensions.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class RectangleExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The rectangle to convert.
+ /// The converted rectangle.
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Rect ToUnityRect(this Rectangle rectangle)
+ {
+ return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/RectangleFExtensions.cs b/X10D.Unity/src/Drawing/RectangleFExtensions.cs
new file mode 100644
index 0000000..6eaf66c
--- /dev/null
+++ b/X10D.Unity/src/Drawing/RectangleFExtensions.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class RectangleFExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The rectangle to convert.
+ /// The converted rectangle.
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Rect ToUnityRect(this RectangleF rectangle)
+ {
+ return new Rect(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/SizeExtensions.cs b/X10D.Unity/src/Drawing/SizeExtensions.cs
new file mode 100644
index 0000000..e7fb47f
--- /dev/null
+++ b/X10D.Unity/src/Drawing/SizeExtensions.cs
@@ -0,0 +1,36 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class SizeExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 ToUnityVector2(this Size size)
+ {
+ return new Vector2(size.Width, size.Height);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2Int ToUnityVector2Int(this Size size)
+ {
+ return new Vector2Int(size.Width, size.Height);
+ }
+}
diff --git a/X10D.Unity/src/Drawing/SizeFExtensions.cs b/X10D.Unity/src/Drawing/SizeFExtensions.cs
new file mode 100644
index 0000000..eae0e30
--- /dev/null
+++ b/X10D.Unity/src/Drawing/SizeFExtensions.cs
@@ -0,0 +1,24 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+using UnityEngine;
+
+namespace X10D.Unity.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class SizeFExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 ToUnityVector2(this SizeF size)
+ {
+ return new Vector2(size.Width, size.Height);
+ }
+}
diff --git a/X10D.Unity/src/Numerics/Vector2Extensions.cs b/X10D.Unity/src/Numerics/Vector2Extensions.cs
index 83afaf6..6ae262c 100644
--- a/X10D.Unity/src/Numerics/Vector2Extensions.cs
+++ b/X10D.Unity/src/Numerics/Vector2Extensions.cs
@@ -1,4 +1,5 @@
using System.Diagnostics.Contracts;
+using System.Drawing;
using System.Runtime.CompilerServices;
using UnityEngine;
@@ -21,6 +22,30 @@ public static class Vector2Extensions
y = vector.y;
}
+ ///
+ /// Converts the current into a .
+ ///
+ /// The vector to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static PointF ToSystemPointF(this Vector2 vector)
+ {
+ return new PointF(vector.x, vector.y);
+ }
+
+ ///
+ /// Converts the current into a .
+ ///
+ /// The vector to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static SizeF ToSystemSizeF(this Vector2 vector)
+ {
+ return new SizeF(vector.x, vector.y);
+ }
+
///
/// Converts the current vector to a .
///
diff --git a/X10D/src/Drawing/PointExtensions.cs b/X10D/src/Drawing/PointExtensions.cs
new file mode 100644
index 0000000..50c708f
--- /dev/null
+++ b/X10D/src/Drawing/PointExtensions.cs
@@ -0,0 +1,52 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+namespace X10D.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class PointExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static Size ToSize(this Point point)
+ {
+ return new Size(point.X, point.Y);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static SizeF ToSizeF(this Point point)
+ {
+ return new SizeF(point.X, point.Y);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static Vector2 ToVector2(this Point point)
+ {
+ return new Vector2(point.X, point.Y);
+ }
+}
diff --git a/X10D/src/Drawing/PointFExtensions.cs b/X10D/src/Drawing/PointFExtensions.cs
new file mode 100644
index 0000000..a961042
--- /dev/null
+++ b/X10D/src/Drawing/PointFExtensions.cs
@@ -0,0 +1,27 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Runtime.CompilerServices;
+
+namespace X10D.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class PointFExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The point to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static SizeF ToSizeF(this PointF point)
+ {
+ return new SizeF(point.X, point.Y);
+ }
+}
diff --git a/X10D/src/Drawing/SizeExtensions.cs b/X10D/src/Drawing/SizeExtensions.cs
new file mode 100644
index 0000000..54c3884
--- /dev/null
+++ b/X10D/src/Drawing/SizeExtensions.cs
@@ -0,0 +1,60 @@
+using System.Diagnostics.Contracts;
+using System.Drawing;
+using System.Numerics;
+using System.Runtime.CompilerServices;
+
+namespace X10D.Drawing;
+
+///
+/// Drawing-related extension methods for .
+///
+public static class SizeExtensions
+{
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static Point ToPoint(this Size size)
+ {
+ return new Point(size.Width, size.Height);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static PointF ToPointF(this Size size)
+ {
+ return new PointF(size.Width, size.Height);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The size to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static Vector2 ToVector2(this Size size)
+ {
+ return new Vector2(size.Width, size.Height);
+ }
+}
diff --git a/X10D/src/Numerics/Vector2Extensions.cs b/X10D/src/Numerics/Vector2Extensions.cs
index eb032eb..11533de 100644
--- a/X10D/src/Numerics/Vector2Extensions.cs
+++ b/X10D/src/Numerics/Vector2Extensions.cs
@@ -1,4 +1,5 @@
using System.Diagnostics.Contracts;
+using System.Drawing;
using System.Numerics;
using System.Runtime.CompilerServices;
@@ -21,6 +22,38 @@ public static class Vector2Extensions
y = vector.Y;
}
+ ///
+ /// Converts the current to a .
+ ///
+ /// The vector to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static PointF ToPointF(this Vector2 vector)
+ {
+ return new PointF(vector.X, vector.Y);
+ }
+
+ ///
+ /// Converts the current to a .
+ ///
+ /// The vector to convert.
+ /// The resulting .
+ [Pure]
+#if NETSTANDARD2_1
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
+#endif
+ public static SizeF ToSizeF(this Vector2 vector)
+ {
+ return new SizeF(vector.X, vector.Y);
+ }
+
///
/// Returns a vector whose Y component is the same as the specified vector, and whose X component is a new value.
///