Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PathSpline.cs
1using SkiaSharp;
3
5{
10 {
11 private readonly ChunkedList<SKPoint> vertices;
12
18 public PathSpline(float X0, float Y0)
19 {
20 this.vertices = new ChunkedList<SKPoint>() { new SKPoint(X0, Y0) };
21 }
22
28 public void Add(float X, float Y)
29 {
30 this.vertices.Add(new SKPoint(X, Y));
31 }
32
37 public SKPoint[] ToArray()
38 {
39 return this.vertices.ToArray();
40 }
41
49 public bool TryGetStart(out float X, out float Y, out float Direction)
50 {
51 int c = this.vertices.Count;
52 if (c<2)
53 {
54 X = Y = Direction = 0;
55 return false;
56 }
57
58 SKPoint P0 = this.vertices[0];
59 SKPoint P1 = this.vertices[1];
60 float dx = P1.X - P0.X;
61 float dy = P1.Y - P0.Y;
62
63 X = P0.X;
64 Y = P0.Y;
65 Direction = LayoutElement.CalcDirection(dx, dy);
66
67 return true;
68 }
69
77 public bool TryGetEnd(out float X, out float Y, out float Direction)
78 {
79 int c = this.vertices.Count;
80 if (c < 2)
81 {
82 X = Y = Direction = 0;
83 return false;
84 }
85
86 SKPoint P0 = this.vertices[c - 2];
87 SKPoint P1 = this.vertices[c - 1];
88 float dx = P1.X - P0.X;
89 float dy = P1.Y - P0.Y;
90
91 X = P1.X;
92 Y = P1.Y;
93 Direction = LayoutElement.CalcDirection(dx, dy);
94
95 return true;
96 }
97 }
98}
bool TryGetStart(out float X, out float Y, out float Direction)
Tries to get start position and initial direction.
Definition: PathSpline.cs:49
SKPoint[] ToArray()
Returns an array of vertices of the spline curve.
Definition: PathSpline.cs:37
bool TryGetEnd(out float X, out float Y, out float Direction)
Tries to get end position and terminating direction.
Definition: PathSpline.cs:77
PathSpline(float X0, float Y0)
Represents a spline curve in a path
Definition: PathSpline.cs:18
Abstract base class for layout elements.
static float CalcDirection(float x1, float y1, float x2, float y2)
Calculates the direction of the pen when drawing from (x1,y1) to (x2,y2).
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
Interface for directed elements.