Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Plot2DLayeredCurveAreaPainter.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
31 try
32 {
33 Brush = new SKPaint()
34 {
35 Style = SKPaintStyle.Fill,
36 Color = Graph.ToColor(Parameters[0])
37 };
38 Path = new SKPath();
39
40 Path = Plot2DCurvePainter.CreateSpline(Points);
41
42 IElement Zero;
44
45 if (Set is IGroup Group)
47 else
48 Zero = new DoubleNumber(0);
49
50 IVector XAxis = VectorDefinition.Encapsulate(new IElement[] { DrawingArea.MinX, DrawingArea.MaxX }, false, null) as IVector;
51 IVector YAxis = VectorDefinition.Encapsulate(new IElement[] { Zero, Zero }, false, null) as IVector;
52
53 PrevPoints = DrawingArea.Scale(XAxis, YAxis);
54
55 if (DrawingArea.MinX.AssociatedObjectValue is string &&
57 {
58 PrevPoints[0].X = Points[0].X;
59 PrevPoints[1].X = Points[Points.Length - 1].X;
60 }
61
62 PrevPoints = (SKPoint[])PrevPoints.Clone();
63 Array.Reverse(PrevPoints);
64 Plot2DCurvePainter.CreateSpline(Path, PrevPoints);
65
66 Path.LineTo(Points[0]);
67
68 Canvas.DrawPath(Path, Brush);
69 }
70 finally
71 {
72 Brush?.Dispose();
73 Path?.Dispose();
74 }
75 }
76 }
77}
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
static SKPath CreateSpline(params SKPoint[] Points)
Creates a Spline path through a given set of points.
Plots a two-dimensional layered area chart, based on a spline instead of a poly-line....
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