Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Backward.cs
1using System.Threading.Tasks;
2using SkiaSharp;
3
5{
11 {
18 public Backward(Layout2DDocument Document, ILayoutElement Parent)
19 : base(Document, Parent)
20 {
21 }
22
26 public override string LocalName => "Backward";
27
34 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
35 {
36 return new Backward(Document, Parent);
37 }
38
45 {
46 if (this.defined)
48
49 return Task.CompletedTask;
50 }
51
58 public virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
59 {
60 if (this.defined)
61 {
62 this.P1 = Path.LastPoint;
63 Path.LineTo(this.P2 = PathState.Backward(this.dist));
64 }
65
66 return Task.CompletedTask;
67 }
68
72 protected SKPoint P1;
73
77 protected SKPoint P2;
78
86 public bool TryGetStart(out float X, out float Y, out float Direction)
87 {
88 X = this.P1.X;
89 Y = this.P1.Y;
90 Direction = CalcDirection(this.P1, this.P2);
91
92 return this.defined;
93 }
94
102 public bool TryGetEnd(out float X, out float Y, out float Direction)
103 {
104 X = this.P2.X;
105 Y = this.P2.Y;
106 Direction = CalcDirection(this.P1, this.P2);
107
108 return this.defined;
109 }
110
111 }
112}
Contains a 2D layout document.
Abstract base class for distance elements.
Definition: Distance.cs:11
float dist
Measured distance
Definition: Distance.cs:85
Draws a line to a point that lies a certain distance backward of the last point, in the current direc...
Definition: Backward.cs:11
bool TryGetStart(out float X, out float Y, out float Direction)
Tries to get start position and initial direction.
Definition: Backward.cs:86
virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
Draws layout entities.
Definition: Backward.cs:58
Backward(Layout2DDocument Document, ILayoutElement Parent)
Draws a line to a point that lies a certain distance backward of the last point, in the current direc...
Definition: Backward.cs:18
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: Backward.cs:34
Task Measure(DrawingState State, PathState PathState)
Measures layout entities and defines unassigned properties.
Definition: Backward.cs:44
override string LocalName
Local name of type of element.
Definition: Backward.cs:26
bool TryGetEnd(out float X, out float Y, out float Direction)
Tries to get end position and terminating direction.
Definition: Backward.cs:102
SKPoint Backward(float Distance)
Moves forward
Definition: PathState.cs:222
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.