Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Plot2DLayeredAreaPainter.cs
1using System;
2using SkiaSharp;
7
9{
15 {
25 public void DrawGraph(SKCanvas Canvas, SKPoint[] Points, object[] Parameters, SKPoint[] PrevPoints, object[] PrevParameters,
27 {
28 SKPaint Brush = null;
29 SKPath Path = null;
30 bool First = true;
31
32 try
33 {
34 Brush = new SKPaint()
35 {
36 Style = SKPaintStyle.Fill,
37 Color = Graph.ToColor(Parameters[0])
38 };
39 Path = new SKPath();
40
41 foreach (SKPoint Point in Points)
42 {
43 if (First)
44 {
45 First = false;
46 Path.MoveTo(Point);
47 }
48 else
49 Path.LineTo(Point);
50 }
51
52 IElement Zero;
54
55 if (Set is IGroup Group)
57 else
58 Zero = new DoubleNumber(0);
59
60 IVector XAxis = VectorDefinition.Encapsulate(new IElement[] { DrawingArea.MinX, DrawingArea.MaxX }, false, null) as IVector;
61 IVector YAxis = VectorDefinition.Encapsulate(new IElement[] { Zero, Zero }, false, null) as IVector;
62
63 PrevPoints = DrawingArea.Scale(XAxis, YAxis);
64
65 if (DrawingArea.MinX.AssociatedObjectValue is string &&
67 {
68 PrevPoints[0].X = Points[0].X;
69 PrevPoints[1].X = Points[Points.Length - 1].X;
70 }
71
72 int i = PrevPoints.Length;
73
74 while (--i >= 0)
75 Path.LineTo(PrevPoints[i]);
76
77 Path.LineTo(Points[0]);
78
79 Canvas.DrawPath(Path, Brush);
80 }
81 finally
82 {
83 Brush?.Dispose();
84 Path?.Dispose();
85 }
86 }
87
88 }
89}
Base class for all types of groups.
Definition: Group.cs:10
abstract IGroupElement AdditiveIdentity
Returns the additive identity of the group.
Definition: Group.cs:53
Base class for all types of sets.
Definition: Set.cs:14
Contains information about the current drawing area.
Definition: DrawingArea.cs:12
SKPoint[] Scale(IVector VectorX, IVector VectorY)
Scales two vectors of equal size to points in a rectangular area.
Definition: DrawingArea.cs:135
IElement MinX
Smallest value of X.
Definition: DrawingArea.cs:60
IElement MaxX
Largest value of X.
Definition: DrawingArea.cs:65
IElement MinY
Smallest value of Y.
Definition: DrawingArea.cs:70
Plots a two-dimensional layered area chart. https://en.wikipedia.org/wiki/Area_chart
void DrawGraph(SKCanvas Canvas, SKPoint[] Points, object[] Parameters, SKPoint[] PrevPoints, object[] PrevParameters, DrawingArea DrawingArea)
Draws the graph on a canvas.
Base class for graphs.
Definition: Graph.cs:79
static SKColor ToColor(object Object)
Converts an object to a color.
Definition: Graph.cs:828
static IElement Encapsulate(Array Elements, bool CanEncapsulateAsMatrix, ScriptNode Node)
Encapsulates the elements of a vector.
Basic interface for all types of elements.
Definition: IElement.cs:20
object AssociatedObjectValue
Associated object value.
Definition: IElement.cs:33
Basic interface for vectors.
Definition: IVector.cs:9
Basic interface for all types of groups.
Definition: IGroup.cs:10
Basic interface for all types of sets.
Definition: ISet.cs:10
Interface for 2D graph drawing functions.
Definition: IPainter2D.cs:10