Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HSL.cs
1using System;
2using System.Collections.Generic;
3using SkiaSharp;
8
10{
15 {
27 {
28 }
29
33 public override string[] DefaultArgumentNames
34 {
35 get
36 {
37 return new string[] { "H", "S", "L" };
38 }
39 }
40
44 public override string FunctionName
45 {
46 get
47 {
48 return "HSL";
49 }
50 }
51
59 {
60 double H = Expression.ToDouble(Arguments[0].AssociatedObjectValue);
61 double S = Expression.ToDouble(Arguments[1].AssociatedObjectValue);
62 double L = Expression.ToDouble(Arguments[2].AssociatedObjectValue);
63
64 H = Math.IEEERemainder(H, 360);
65 if (H < 0)
66 H += 360;
67
68 if (S < 0)
69 S = 0;
70 else if (S > 1)
71 S = 1;
72
73 if (L < 0)
74 L = 0;
75 else if (L > 1)
76 L = 1;
77
78 return new ObjectValue(Graph.ToColorHSL(H, S, L));
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
Returns a color value using HSL coordinates.
Definition: HSL.cs:15
override string[] DefaultArgumentNames
Default Argument names
Definition: HSL.cs:34
HSL(ScriptNode H, ScriptNode S, ScriptNode L, int Start, int Length, Expression Expression)
Returns a color value using HSL coordinates.
Definition: HSL.cs:25
override string FunctionName
Name of the function
Definition: HSL.cs:45
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: HSL.cs:58
Base class for graphs.
Definition: Graph.cs:79
static SKColor ToColorHSL(double H, double S, double L)
Creates a Color from its HSL representation.
Definition: Graph.cs:846
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes3Scalar
Three 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