Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RGBA.cs
1using System;
2using System.Collections.Generic;
3using SkiaSharp;
8
10{
15 {
28 {
29 }
30
34 public override string[] DefaultArgumentNames
35 {
36 get
37 {
38 return new string[] { "R", "G", "B", "A" };
39 }
40 }
41
45 public override string FunctionName
46 {
47 get
48 {
49 return "RGBA";
50 }
51 }
52
60 {
61 int R = (int)(Expression.ToDouble(Arguments[0].AssociatedObjectValue) + 0.5);
62 int G = (int)(Expression.ToDouble(Arguments[1].AssociatedObjectValue) + 0.5);
63 int B = (int)(Expression.ToDouble(Arguments[2].AssociatedObjectValue) + 0.5);
64 int A = (int)(Expression.ToDouble(Arguments[3].AssociatedObjectValue) + 0.5);
65
66 if (R < 0)
67 R = 0;
68 else if (R > 255)
69 R = 255;
70
71 if (G < 0)
72 G = 0;
73 else if (G > 255)
74 G = 255;
75
76 if (B < 0)
77 B = 0;
78 else if (B > 255)
79 B = 255;
80
81 if (A < 0)
82 A = 0;
83 else if (A > 255)
84 A = 255;
85
86 return new ObjectValue(new SKColor((byte)R, (byte)G, (byte)B, (byte)A));
87 }
88 }
89}
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
Returns a color value using RGB coordinates, and an alpha component.
Definition: RGBA.cs:15
override string FunctionName
Name of the function
Definition: RGBA.cs:46
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: RGBA.cs:59
override string[] DefaultArgumentNames
Default Argument names
Definition: RGBA.cs:35
RGBA(ScriptNode R, ScriptNode G, ScriptNode B, ScriptNode A, int Start, int Length, Expression Expression)
Returns a color value using RGB coordinates, and an alpha component.
Definition: RGBA.cs:26
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes4Scalar
Four scalar parameters.
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