-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVector2Helper.cs
More file actions
57 lines (52 loc) · 1.55 KB
/
Vector2Helper.cs
File metadata and controls
57 lines (52 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Drawing;
using Gdk;
using Size = System.Drawing.Size;
namespace MetaphysicsIndustries.Ligra
{
public static class Vector2Helper
{
public static Vector2 ToVector2(this SizeF v)
{
return new Vector2(v.Width, v.Height);
}
public static Vector2 ToVector2(this PointF v)
{
return new Vector2(v.X, v.Y);
}
public static Vector2 ToVector2(this Size v)
{
return new Vector2(v.Width, v.Height);
}
public static Vector2 ToVector2(this Gdk.Size size)
{
return new Vector2(size.Width, size.Height);
}
public static Size ToSize(this Vector2 v)
{
return new Size(v.X.RoundToInt(), v.Y.RoundToInt());
}
public static Gdk.Point ToGdkPoint(this Vector2 v)
{
return new Gdk.Point(v.X.RoundToInt(), v.Y.RoundToInt());
}
public static Vector2[] ToVector2(this PointF[] points)
{
if (points == null) return null;
var v = new Vector2[points.Length];
int i;
for (i = 0; i < v.Length; i++)
v[i] = points[i].ToVector2();
return v;
}
public static PointF[] ToSwf(this Vector2[] points)
{
if (points == null) return null;
var v = new PointF[points.Length];
int i;
for (i = 0; i < v.Length; i++)
v[i] = new PointF(points[i].X, points[i].Y);
return v;
}
}
}