-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPath.cs
More file actions
83 lines (69 loc) · 2.16 KB
/
Path.cs
File metadata and controls
83 lines (69 loc) · 2.16 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
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Numerics;
using Microsoft.Graphics.Canvas.Geometry;
using MyScript.IInk.Graphics;
using MyScript.InteractiveInk.Annotations;
namespace MyScript.InteractiveInk.UI.Commands
{
public sealed partial class Path
{
[CanBeNull] public CanvasPathBuilder PathBuilder { get; set; }
[CanBeNull]
public CanvasGeometry Geometry
{
get
{
if (PathBuilder == null)
{
return null;
}
if (!IsInFigure)
{
return CanvasGeometry.CreatePath(PathBuilder);
}
PathBuilder.EndFigure(CanvasFigureLoop.Open);
IsInFigure = false;
return CanvasGeometry.CreatePath(PathBuilder);
}
}
private bool IsInFigure { get; set; }
}
/// <summary>
/// Implements <see cref="IPath" />.
/// <inheritdoc cref="IPath" />
/// </summary>
public sealed partial class Path : IPath
{
public void MoveTo(float x, float y)
{
if (IsInFigure)
{
PathBuilder?.EndFigure(CanvasFigureLoop.Open);
}
PathBuilder?.BeginFigure(x, y);
IsInFigure = true;
}
public void LineTo(float x, float y)
{
PathBuilder?.AddLine(x, y);
}
public void CurveTo(float x1, float y1, float x2, float y2, float x, float y)
{
PathBuilder?.AddCubicBezier(new Vector2(x1, y1), new Vector2(x2, y2), new Vector2(x, y));
}
public void QuadTo(float x1, float y1, float x, float y)
{
PathBuilder?.AddQuadraticBezier(new Vector2(x1, y1), new Vector2(x, y));
}
public void ArcTo(float rx, float ry, float phi, bool fA, bool fS, float x, float y)
{
throw new NotImplementedException();
}
public void ClosePath()
{
PathBuilder?.EndFigure(CanvasFigureLoop.Closed);
IsInFigure = false;
}
public uint UnsupportedOperations => (uint)PathOperation.ARC_OPS;
}
}