Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Polygon.cs
1using System.Threading.Tasks;
2using SkiaSharp;
4
6{
10 public class Polygon : Vertices
11 {
17 public Polygon(Layout2DDocument Document, ILayoutElement Parent)
18 : base(Document, Parent)
19 {
20 }
21
25 public override string LocalName => "Polygon";
26
33 public override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
34 {
35 return new Polygon(Document, Parent);
36 }
37
42 public override async Task Draw(DrawingState State)
43 {
44 if (this.defined)
45 {
46 using (SKPath Path = new SKPath())
47 {
48 Vertex First = null;
49
50 foreach (Vertex V in this.points)
51 {
52 if (First is null)
53 {
54 Path.MoveTo(V.XCoordinate, V.YCoordinate);
55 First = V;
56 }
57 else
58 Path.LineTo(V.XCoordinate, V.YCoordinate);
59 }
60
61 Path.Close();
62
63 SKPaint Fill = await this.TryGetFill(State);
64 if (!(Fill is null))
65 State.Canvas.DrawPath(Path, Fill);
66
67 SKPaint Pen = await this.TryGetPen(State);
68 if (!(Pen is null))
69 State.Canvas.DrawPath(Path, Pen);
70 }
71 }
72
73 await base.Draw(State);
74 }
75 }
76}
Contains a 2D layout document.
SKCanvas Canvas
Current drawing canvas.
async Task< SKPaint > TryGetPen(DrawingState State)
Tries to get the pen associated with the element, if one is defined.
Definition: Figure.cs:111
async Task< SKPaint > TryGetFill(DrawingState State)
Tries to get the filling of the figure, if one is defined.
Definition: Figure.cs:130
override ILayoutElement Create(Layout2DDocument Document, ILayoutElement Parent)
Creates a new instance of the layout element.
Definition: Polygon.cs:33
Polygon(Layout2DDocument Document, ILayoutElement Parent)
A polygon
Definition: Polygon.cs:17
override async Task Draw(DrawingState State)
Draws layout entities.
Definition: Polygon.cs:42
override string LocalName
Local name of type of element.
Definition: Polygon.cs:25
bool defined
If element is well-defined.
Defines a vertex in the graf
Definition: Vertex.cs:7
float YCoordinate
Measured Y-coordinate
Definition: Vertex.cs:42
float XCoordinate
Measured X-coordinate
Definition: Vertex.cs:37
Base interface for all layout elements.