Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Alpha.cs
1using System.Threading.Tasks;
2using SkiaSharp;
6
8{
13 {
24 {
25 }
26
30 public override string[] DefaultArgumentNames => new string[] { "Color", "Alpha" };
31
35 public override string FunctionName => nameof(Alpha);
36
40 public override bool UpgradeScalarsToSameSet => false;
41
50 {
51 return this.Evaluate(Argument1.AssociatedObjectValue, Argument2.AssociatedObjectValue);
52 }
53
62 {
63 return Task.FromResult<IElement>(this.Evaluate(Argument1.AssociatedObjectValue, Argument2.AssociatedObjectValue));
64 }
65
66 private IElement Evaluate(object Argument1, object Argument2)
67 {
68 SKColor Color = Graph.ToColor(Argument1);
70 byte A;
71
72 if (Alpha < 0)
73 A = 0;
74 else if (Alpha > 255)
75 A = 255;
76 else
77 A = (byte)(Alpha + 0.5);
78
79 return new ObjectValue(new SKColor(Color.Red, Color.Green, Color.Blue, A));
80 }
81
90 {
91 return this.Evaluate(Argument1, Argument2);
92 }
93 }
94}
Class managing a script expression.
Definition: Expression.cs:41
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:5110
Sets the Alpha channel of a color.
Definition: Alpha.cs:13
override string FunctionName
Name of the function
Definition: Alpha.cs:35
override Task< IElement > EvaluateScalarAsync(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: Alpha.cs:61
Alpha(ScriptNode Color, ScriptNode Alpha, int Start, int Length, Expression Expression)
Sets the Alpha channel of a color.
Definition: Alpha.cs:22
override IElement EvaluateScalar(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Alpha.cs:49
override string[] DefaultArgumentNames
Default Argument names
Definition: Alpha.cs:30
override bool UpgradeScalarsToSameSet
If scalars should be upgraded to the same set before evaluation.
Definition: Alpha.cs:40
override IElement EvaluateScalar(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: Alpha.cs:89
Returns a color value from a string.
Definition: Color.cs:14
Base class for graphs.
Definition: Graph.cs:88
static SKColor ToColor(object Object)
Converts an object to a color.
Definition: Graph.cs:844
Base class for funcions of two scalar variables.
ScriptNode Argument2
Function argument 2.
ScriptNode Argument1
Function argument 1.
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
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:21