Studio Yotsuba
Back to Node List

Expression Float

expression_float

Evaluates a small expression and outputs a float

Reviewed
Guide available

Input Ports

NameTypeDescription
X
x
Number
Number variable x
Y
y
Number
Number variable y
Z
z
Number
Number variable z
W
w
Number
Number variable w
Vec
vec
Vec2
Optional vec2 variable
Flag
flag
Bool
Optional bool variable

Output Ports

NameTypeDescription
Value
value
Float
Float result of the expression

Parameters

NameTypeDefaultRangeDescription / Options
X
x
Float
0-10000–10000 / step 0.01

Fallback value for x when the input pin is not connected

Y
y
Float
0-10000–10000 / step 0.01

Fallback value for y when the input pin is not connected

Z
z
Float
0-10000–10000 / step 0.01

Fallback value for z when the input pin is not connected

W
w
Float
0-10000–10000 / step 0.01

Fallback value for w when the input pin is not connected

Vec X
vec_x
Float
0-10000–10000 / step 0.01

Fallback X component for vec when the vec input pin is not connected

Vec Y
vec_y
Float
0-10000–10000 / step 0.01

Fallback Y component for vec when the vec input pin is not connected

Flag
flag
Bool
false—

Fallback bool value when the flag input pin is not connected

Expression
expression
Text
x—

Available variables: x, y, z, w, vec, vx, vy, flag, time, frame, total_frames Examples: - x + y * 2 - sin(time * pi * 2) - if(flag, x, y) Connected input pins override Inspector values.

Overview

Evaluates a short formula written as text and outputs one number. It can consolidate a calculation that would require several math_op or math_func nodes into one, such as floor(x*4)/4. Use it to tidy a graph when numeric wiring becomes hard to read.

Usage tips

  • A single expression is usually clearer for calculations that would need three or more numeric nodes. For one simple operation, math_op makes the intent more visible in the graph.
  • You can use time / frame directly in an expression without connecting time_source. For example, sin(time * pi * 2) produces one sine-wave cycle.
  • if(condition, a, b) replaces the numeric equivalent of compare + switch with one expression.
  • The go-to pixel snap expression is floor(x * number_of_steps) / number_of_steps.

Related nodes

  • math_op / math_func — node-based equivalents
  • list_map — transform every list item with the same expression engine
  • compare / switch — propagate a Bool condition to other types
  • float_input — supply variables

Read this first

  • The x, y, z, w, vec, and flag used here are not variables created in the variable panel.
  • They are input pin names belonging to the Expression node itself.
  • You can also enter x, y, z, w, vec_x, vec_y, and flag directly in the Inspector.
  • To use a variable created in the variable panel, retrieve it with Variable Ref or a similar node and connect it to the corresponding input pin.
  • When a value is connected to an input pin, that value takes priority over the Inspector value.
  • Unconnected inputs are treated as follows:
    • x, y, z, w = 0
    • vec = [vec_x, vec_y]
    • flag = false

Available items

  • Variables: x, y, z, w, vec, vx, vy, flag, time, frame, total_frames
  • Operators: + - * / %, == != < <= > >=, && || !
  • Functions: min, max, clamp, abs, floor, ceil, round, sign, sin, cos, tan, sqrt, pow, lerp, vec2, x, y, length, if

Common expressions

  • x + y * 2
  • sin(time * pi * 2)
  • if(flag, x, y)
  • length(vec) * 0.5

Detailed examples

Example 1: Simple addition

  • Set x to 0.5.
  • Set y to 2.
  • Set expression = x + y * 2.
value = 4.5

Example 2: Leaving inputs unconnected

  • Do not connect any inputs.
  • Set expression = x + 1.

In this case, x is treated as 0.

value = 1

Example 3: Using time

  • Set expression = sin(time * pi * 2).

As time changes from 0.0 to 1.0, the result completes one sine-wave cycle.

When to use it

  • To write a small formula that does not justify arranging several numeric nodes
  • To test an expression on its own before putting it in ListMap

Notes

  • && / || skip the right side once the result is known, and if(condition, A, B) evaluates only the selected branch.
  • Reversed clamp bounds are swapped, sign(0) = 0, and % is the Euclidean remainder in 0 <= result < |right operand|. As with the Math nodes, division or modulo by zero and sqrt of a negative value produce an error.
  • This is not intended for long logic or operations with side effects.
  • Version 1 is a lightweight escape hatch.
  • While editing an expression, even an incomplete intermediate string is evaluated immediately, so an error may appear temporarily.
Back to Node List