-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGeometryElement.cs
70 lines (56 loc) · 1.79 KB
/
GeometryElement.cs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using MonoGame.Extended.Drawing.Geometries;
namespace MonoGame.Extended.Drawing;
[StructLayout(LayoutKind.Explicit, Pack = 1)]
internal struct GeometryElement
{
public GeometryElement(Vector2 lineSegment)
: this()
{
Type = GeometryElementType.Line;
LineSegment = lineSegment;
}
public GeometryElement(ArcSegment arcSegment)
: this()
{
Type = GeometryElementType.Arc;
ArcSegment = arcSegment;
}
public GeometryElement(BezierSegment bezierSegment)
: this()
{
Type = GeometryElementType.Bezier;
BezierSegment = bezierSegment;
}
public GeometryElement(QuadraticBezierSegment quadraticBezierSegment)
: this()
{
Type = GeometryElementType.QuadraticBezier;
QuadraticBezierSegment = quadraticBezierSegment;
}
/// <summary>
/// Only used for <see cref="EllipseGeometry"/>; don't use it for anything else!
/// </summary>
public GeometryElement(MathArcSegment mathArcSegment)
: this()
{
Type = GeometryElementType.MathArc;
MathArcSegment = mathArcSegment;
}
[field: FieldOffset(0)]
public GeometryElementType Type { get; set; }
[field: FieldOffset(4)]
public Vector2 LineSegment { get; set; }
[field: FieldOffset(4)]
public ArcSegment ArcSegment { get; set; }
[field: FieldOffset(4)]
public BezierSegment BezierSegment { get; set; }
[field: FieldOffset(4)]
public QuadraticBezierSegment QuadraticBezierSegment { get; set; }
/// <summary>
/// Only used for <see cref="EllipseGeometry"/>; don't use it for anything else!
/// </summary>
[field: FieldOffset(4)]
public MathArcSegment MathArcSegment { get; set; }
}