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;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using SkiaSharp;
9
11{
16 {
27 {
28 }
29
33 public override string[] DefaultArgumentNames
34 {
35 get
36 {
37 return new string[] { "Color", "Alpha" };
38 }
39 }
40
44 public override string FunctionName
45 {
46 get
47 {
48 return "Alpha";
49 }
50 }
51
60 {
61 return this.Evaluate(Argument1.AssociatedObjectValue, Argument2.AssociatedObjectValue);
62 }
63
72 {
73 return Task.FromResult<IElement>(this.Evaluate(Argument1.AssociatedObjectValue, Argument2.AssociatedObjectValue));
74 }
75
76 private IElement Evaluate(object Argument1, object Argument2)
77 {
78 SKColor Color = Graph.ToColor(Argument1);
80 byte A;
81
82 if (Alpha < 0)
83 A = 0;
84 else if (Alpha > 255)
85 A = 255;
86 else
87 A = (byte)(Alpha + 0.5);
88
89 return new ObjectValue(new SKColor(Color.Red, Color.Green, Color.Blue, A));
90 }
91
100 {
101 return this.Evaluate(Argument1, Argument2);
102 }
103 }
104}
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
Sets the Alpha channel of a color.
Definition: Alpha.cs:16
override string FunctionName
Name of the function
Definition: Alpha.cs:45
override Task< IElement > EvaluateScalarAsync(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: Alpha.cs:71
Alpha(ScriptNode Color, ScriptNode Alpha, int Start, int Length, Expression Expression)
Sets the Alpha channel of a color.
Definition: Alpha.cs:25
override IElement EvaluateScalar(IElement Argument1, IElement Argument2, Variables Variables)
Evaluates the function on a scalar argument.
Definition: Alpha.cs:59
override string[] DefaultArgumentNames
Default Argument names
Definition: Alpha.cs:34
override IElement EvaluateScalar(string Argument1, string Argument2, Variables Variables)
Evaluates the function on two scalar arguments.
Definition: Alpha.cs:99
Returns a color value from a string.
Definition: Color.cs:14
Base class for graphs.
Definition: Graph.cs:79
static SKColor ToColor(object Object)
Converts an object to a color.
Definition: Graph.cs:828
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:20