Files
ausboss-ComfyUI-AusBoss/js/docs/AUSBOSS_NODES_MathExpression.md
T
ausboss 358ea00b4b Name controls in the help pages the way the node faces show them
Help pages named the raw widget (divisible_by, max_frames, color_match)
where the card shows a label (Multiple, Limit, Tone match), so a reader
could not find the control. Each such control now reads as the visible
label with the widget name beside it, and option values show the text
on the segment (match a, hist, cover, guided).
2026-09-24 00:46:14 -05:00

35 lines
1.4 KiB
Markdown

# Math Expression
Evaluates one arithmetic expression over the inputs `a`, `b` and `c` and
returns the result as both `FLOAT` and `INT` — width and height math,
strength ramps, frame counts.
## Controls
- **f(a, b, c)** (`expression`): The arithmetic to evaluate. Allowed:
numbers, the names `a`/`b`/`c`, the operators `+ - * / // % **`,
parentheses, unary minus, and the functions `min`, `max`, `abs`, `round`,
`floor`, `ceil`, `sqrt`.
Examples: `a * 2`, `floor(a / 64) * 64`, `min(a, b) + 0.5`,
`sqrt(a*a + b*b)`.
- **a**, **b**, **c**: The values the expression reads, as three sockets on
the node's left edge that take a `FLOAT` or an `INT`. An unwired one reads
as `0`, and an unused one costs nothing; a constant belongs in the
expression itself (`a * 2`, `floor(a / 64) * 64`).
## Outputs
- **float**: The result as a float.
- **int**: The result rounded to the nearest whole number; halves round away
from zero (`2.5` becomes `3`, `-2.5` becomes `-3`).
## Safety
The expression is parsed with Python's `ast` module and walked against a
whitelist — it is never passed to `eval`. Anything outside the grammar above
(other names, attribute access, subscripts, strings, comparisons) stops the
run with an error naming what to remove, so a workflow shared by someone else
cannot smuggle code through this node. Division by zero and overflowing
results are clear errors rather than a crash or an `inf` traveling
downstream.