Class FlexalonExpression
- Namespace
- Flexalon
- Assembly
- Flexalon.dll
A reusable, case-sensitive scalar expression. Supports invariant-culture numbers,
-
-
- /, unary +/-, parentheses, min/max (two or more arguments), and clamp(value, min, max). An optional calc(expression) wrapper is also accepted. Bare numbers use the caller's units; no implicit percentages or unit suffixes exist.
-
References: self/parent/canvas/screen.width/height/depth/x/y/z/left/right/bottom/top/back/front. x/y/z are bounds CENTER coordinates, not transform pivots. Width/height/depth are nonnegative bounds sizes. Left/bottom/back are minimum X/Y/Z; right/top/front are maximum X/Y/Z (front is +Z, regardless of the viewing camera).
[Serializable]
public sealed class FlexalonExpression
- Inheritance
-
objectFlexalonExpression
Constructors
FlexalonExpression()
Creates an expression that evaluates to zero.
public FlexalonExpression()
FlexalonExpression(string)
Creates an expression from text.
public FlexalonExpression(string source)
Parameters
sourcestring
Fields
Source
The expression text, such as "parent.width / 2".
public string Source
Field Value
- string
Properties
References
The bounds this expression refers to, such as self or parent.
public FlexalonExpressionReferences References { get; }
Property Value
Methods
TryEvaluate(FlexalonExpressionContext, out float, out string)
Evaluates with the latest supplied measurements. Returns an error for missing references, division by zero, reversed clamp limits, or non-finite results; value is zero on failure. The caller chooses whether to retain its previous value or display another fallback.
public bool TryEvaluate(FlexalonExpressionContext context, out float value, out string error)
Parameters
contextFlexalonExpressionContextvaluefloaterrorstring
Returns
- bool
TryValidate(out string)
Checks whether Source is a valid expression.
public bool TryValidate(out string error)
Parameters
errorstringA description of the problem, or null if the expression is valid.
Returns
- bool
True if the expression is valid.