Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Plot2DHorizontalLinePainter.cs
1using SkiaSharp;
2using System;
3
5{
10 {
20 public void DrawGraph(SKCanvas Canvas, SKPoint[] Points, object[] Parameters, SKPoint[] PrevPoints, object[] PrevParameters,
22 {
23 SKPaint Pen = null;
24 SKPath Path = null;
25 SKPoint Last = default;
26 bool First = true;
27 int Mode = Math.Sign(Expression.ToDouble(Parameters[0]));
28
29 try
30 {
31 Pen = Graph.ToPen(Parameters[1], Parameters[2]);
32 Path = new SKPath();
33
34 foreach (SKPoint Point in Points)
35 {
36 if (First)
37 {
38 First = false;
39 Path.MoveTo(Point);
40 }
41 else if (Point.Y == Last.Y || Point.X == Last.X)
42 Path.LineTo(Point);
43 else
44 {
45 switch (Mode)
46 {
47 case -1:
48 Path.LineTo(Last.X, Point.Y);
49 Path.LineTo(Point);
50 break;
51
52 case 0:
53 float xm = (Last.X + Point.X) / 2;
54 Path.LineTo(xm, Last.Y);
55 Path.LineTo(xm, Point.Y);
56 Path.LineTo(Point);
57 break;
58
59 case 1:
60 Path.LineTo(Point.X, Last.Y);
61 Path.LineTo(Point);
62 break;
63 }
64
65 Path.LineTo(Point);
66 }
67
68 Last = Point;
69 }
70
71 Canvas.DrawPath(Path, Pen);
72 }
73 finally
74 {
75 Pen?.Dispose();
76 Path?.Dispose();
77 }
78 }
79
80 }
81}
Class managing a script expression.
Definition: Expression.cs:39
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:4824
Contains information about the current drawing area.
Definition: DrawingArea.cs:12
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 SKPaint ToPen(object Object, object Size)
Converts an object to a pen value.
Definition: Graph.cs:769
Interface for 2D graph drawing functions.
Definition: IPainter2D.cs:10