-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVGPolygon.cs
More file actions
70 lines (56 loc) · 2.07 KB
/
SVGPolygon.cs
File metadata and controls
70 lines (56 loc) · 2.07 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
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Text.RegularExpressions;
using OpenTK.Mathematics;
namespace FreeFrame.Components.Shapes
{
public class SVGPolygon : Shape
{
readonly Regex _pointsRegex = new(@" *(\d+) *, *(\d+) *"); // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/points
#region Geometry properties
List<(int, int)> _points = new();
#endregion
// TODO: Also add Polyline https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/points
public SVGPolygon(XmlReader reader)
{
string points = reader["points"] ?? throw new Exception("points not here"); // TODO: Error handler if points is note here
MatchCollection matches = _pointsRegex.Matches(points); // Retrieve every points
foreach (Match match in matches)
_points.Add((Convert.ToInt32(match.Groups[1].Value), Convert.ToInt32(match.Groups[2].Value)));
}
public override void Draw(Vector2i clientSize) => throw new NotImplementedException();
public override List<Vector2i> GetSelectablePoints()
{
throw new NotImplementedException();
}
public override float[] GetVertices()
{
throw new NotImplementedException();
}
public override uint[] GetVerticesIndexes()
{
throw new NotImplementedException();
}
public override void ImplementObject()
{
throw new NotImplementedException();
}
public override void Move(Vector2i position)
{
throw new NotImplementedException();
}
public override void Resize(Vector2i size)
{
throw new NotImplementedException();
}
public override string ToString()
{
string output = "points: ";
foreach ((int x, int y) point in _points)
output += string.Format("{0},{1} ", point.x, point.y);
return output.Trim();
}
}
}