Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Polygon2D.cs
4
6{
17 {
18 private static readonly ArgumentType[] argumentTypes3Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar };
19 private static readonly ArgumentType[] argumentTypes2Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector };
20
30 : base(new ScriptNode[] { X, Y }, argumentTypes2Parameters, Start, Length, Expression)
31 {
32 }
33
44 : base(new ScriptNode[] { X, Y, Color }, argumentTypes3Parameters, Start, Length, Expression)
45 {
46 }
47
51 public override string FunctionName => nameof(Polygon2D);
52
56 public override string[] DefaultArgumentNames
57 {
58 get { return new string[] { "x", "y", "color" }; }
59 }
60
68 {
69 if (!(Arguments[0] is IVector X))
70 throw new ScriptRuntimeException("Expected vector for X argument.", this);
71
72 if (!(Arguments[1] is IVector Y))
73 throw new ScriptRuntimeException("Expected vector for Y argument.", this);
74
75 int Dimension = X.Dimension;
76 if (Y.Dimension != Dimension)
77 throw new ScriptRuntimeException("Vector size mismatch.", this);
78
79 IElement Color = Arguments.Length <= 2 ? null : Arguments[2];
80
81 return new Graph2D(Variables, X, Y, new Polygon2DPainter(), false, false, this,
82 Color?.AssociatedObjectValue ?? Graph.DefaultColor);
83 }
84 }
85}
Class managing a script expression.
Definition: Expression.cs:39
Plots a two-dimensional polygon.
Definition: Polygon2D.cs:17
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: Polygon2D.cs:67
Polygon2D(ScriptNode X, ScriptNode Y, ScriptNode Color, int Start, int Length, Expression Expression)
Plots a two-dimensional polygon.
Definition: Polygon2D.cs:43
Polygon2D(ScriptNode X, ScriptNode Y, int Start, int Length, Expression Expression)
Plots a two-dimensional polygon.
Definition: Polygon2D.cs:29
override string FunctionName
Name of the function
Definition: Polygon2D.cs:51
override string[] DefaultArgumentNames
Default Argument names
Definition: Polygon2D.cs:57
Handles two-dimensional graphs.
Definition: Graph2D.cs:26
Base class for graphs.
Definition: Graph.cs:79
static readonly SKColor DefaultColor
Default color: Red
Definition: Graph.cs:118
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for vectors.
Definition: IVector.cs:9
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9