Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CloseLine.cs
1using System.Threading.Tasks;
2using SkiaSharp;
3
5{
10 {
16 public CloseLine(Layout2DDocument Document, ILayoutElement Parent)
17 : base(Document, Parent)
18 {
19 }
20
24 public override string LocalName => "CloseLine";
25
32 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
33 {
34 return new CloseLine(Document, Parent);
35 }
36
42 public virtual Task Measure(DrawingState State, PathState PathState)
43 {
44 if (this.defined)
46
47 return Task.CompletedTask;
48 }
49
56 public virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
57 {
58 if (this.defined)
59 {
60 this.P1 = Path.LastPoint;
62 this.P2 = Path.LastPoint;
63 }
64
65 return Task.CompletedTask;
66 }
67
71 protected SKPoint P1;
72
76 protected SKPoint P2;
77
85 public bool TryGetStart(out float X, out float Y, out float Direction)
86 {
87 X = this.P1.X;
88 Y = this.P1.Y;
89 Direction = CalcDirection(this.P1, this.P2);
90
91 return this.defined;
92 }
93
101 public bool TryGetEnd(out float X, out float Y, out float Direction)
102 {
103 X = this.P2.X;
104 Y = this.P2.Y;
105 Direction = CalcDirection(this.P1, this.P2);
106
107 return this.defined;
108 }
109
110 }
111}
Contains a 2D layout document.
Closes a path (i.e. returns to the origin), using a line.
Definition: CloseLine.cs:10
override string LocalName
Local name of type of element.
Definition: CloseLine.cs:24
bool TryGetEnd(out float X, out float Y, out float Direction)
Tries to get end position and terminating direction.
Definition: CloseLine.cs:101
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: CloseLine.cs:32
virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
Draws layout entities.
Definition: CloseLine.cs:56
CloseLine(Layout2DDocument Document, ILayoutElement Parent)
Closes a path (i.e. returns to the origin), using a line.
Definition: CloseLine.cs:16
bool TryGetStart(out float X, out float Y, out float Direction)
Tries to get start position and initial direction.
Definition: CloseLine.cs:85
virtual Task Measure(DrawingState State, PathState PathState)
Measures layout entities and defines unassigned properties.
Definition: CloseLine.cs:42
void CloseLine()
Closes the current contour, using a line.
Definition: PathState.cs:123
Abstract base class for layout elements.
bool defined
If element is well-defined.
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).
Interface for directed elements.
Base interface for all layout elements.