Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
QuadraticTo.cs
1using System.Threading.Tasks;
2using SkiaSharp;
3
5{
10 {
17 : base(Document, Parent)
18 {
19 }
20
24 public override string LocalName => "QuadraticTo";
25
32 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
33 {
34 return new QuadraticTo(Document, Parent);
35 }
36
42 public virtual Task Measure(DrawingState State, PathState PathState)
43 {
44 if (this.defined)
45 {
48 }
49
50 return Task.CompletedTask;
51 }
52
59 public virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
60 {
61 if (this.defined)
62 {
63 this.P0 = Path.LastPoint;
64 this.P1 = new SKPoint(this.xCoordinate, this.yCoordinate);
65 this.P2 = new SKPoint(this.xCoordinate2, this.yCoordinate2);
66
69 Path.QuadTo(this.P1, this.P2);
70 }
71
72 return Task.CompletedTask;
73 }
74
78 protected SKPoint P0;
79
83 protected SKPoint P1;
84
88 protected SKPoint P2;
89
97 public bool TryGetStart(out float X, out float Y, out float Direction)
98 {
99 float dx = P1.X - P0.X;
100 float dy = P1.Y - P0.Y;
101
102 X = this.P0.X;
103 Y = this.P0.Y;
104 Direction = CalcDirection(dx, dy);
105
106 return this.defined;
107 }
108
116 public bool TryGetEnd(out float X, out float Y, out float Direction)
117 {
118 float dx = P2.X - P1.X;
119 float dy = P2.Y - P1.Y;
120
121 X = this.P2.X;
122 Y = this.P2.Y;
123 Direction = CalcDirection(dx, dy);
124
125 return this.defined;
126 }
127
128 }
129}
Contains a 2D layout document.
void Set(float X, float Y)
Sets a new coordinate
Definition: PathState.cs:161
Draws a quadratic curve to a point, relative to the origio of the current container
Definition: QuadraticTo.cs:10
virtual Task Measure(DrawingState State, PathState PathState)
Measures layout entities and defines unassigned properties.
Definition: QuadraticTo.cs:42
bool TryGetEnd(out float X, out float Y, out float Direction)
Tries to get end position and terminating direction.
Definition: QuadraticTo.cs:116
bool TryGetStart(out float X, out float Y, out float Direction)
Tries to get start position and initial direction.
Definition: QuadraticTo.cs:97
override string LocalName
Local name of type of element.
Definition: QuadraticTo.cs:24
QuadraticTo(Layout2DDocument Document, ILayoutElement Parent)
Draws a quadratic curve to a point, relative to the origio of the current container
Definition: QuadraticTo.cs:16
virtual Task Draw(DrawingState State, PathState PathState, SKPath Path)
Draws layout entities.
Definition: QuadraticTo.cs:59
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: QuadraticTo.cs:32
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).
Abstract base class for layout elements with two points.
Definition: Point2.cs:11
float yCoordinate2
Measured Y-coordinate
Definition: Point2.cs:122
float xCoordinate2
Measured X-coordinate
Definition: Point2.cs:117
float yCoordinate
Measured Y-coordinate
Definition: Point.cs:122
float xCoordinate
Measured X-coordinate
Definition: Point.cs:117
Interface for directed elements.
Base interface for all layout elements.