Back to Node List

Expression Vec2

expression_vec2

Evaluates a small expression and outputs a vec2

Reviewed
Guide available
The node name and summary are available in English. Port, parameter, and article details are currently shown in Japanese.

Input Ports

NameTypeDescription
X
x
Number
数値変数 x です
Y
y
Number
数値変数 y です
Vec
vec
Vec2
必要なら使える Vec2 変数です
フラグ
flag
Bool
必要なら使える Bool 変数です

Output Ports

NameTypeDescription
value
Vec2
式を評価した結果の Vec2 です

Parameters

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

入力ピンが未接続の時に使う x の値です

Y
y
Float
0-10000–10000 / step 0.01

入力ピンが未接続の時に使う y の値です

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

vec 入力ピンが未接続の時に使う X 成分です

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

vec 入力ピンが未接続の時に使う Y 成分です

フラグ
flag
Bool
false

flag 入力ピンが未接続の時に使う真偽値です

expression
Text
vec2(x, y)

Vec2 を返す式です。 記述例: - vec2(x, y) - vec2(x + 1, y - 1) - vec + vec2(2, 0) 入力ピンがつながっている時は、Inspector の値より入力ピンが優先されます。

Overview

Produces one 2D vector (Vec2) from a short expression. Its current main path is to reuse vector calculations through the vec input of another Expression node or of list_map / list_filter.

Usage tips

  • The go-to moving coordinates are vec2(sin(time*pi*2), cos(time*pi*2)) for circular motion and vec2(time * 32, 0) for horizontal scrolling. Pass the result to another Expression node's vec input and read its components with x(vec) / y(vec).
  • Round offsets to integers to keep pixel art stable: vec2(floor(x), floor(y)).
  • It is also useful simply to combine two numbers into a Vec2 (a number-to-Vec2 conversion point).

Related nodes

  • expression_float / expression_bool — reuse the result through their vec input
  • list_map / list_filter — reuse the result through the list expression's vec input
  • time_source — supplies time (the expression's built-in time is also available)

Read this first

  • The x, y, vec, and flag names here are separate from variables created in the Variables panel.
  • They are the input pin names of the Expression node itself.
  • You can also enter x, y, vec_x, vec_y, and flag directly in the Inspector.
  • To use a variable from the Variables panel, retrieve it with Variable Ref or a similar node and connect it to the relevant input pin.
  • When a value is connected to an input pin, the input-pin value takes precedence over the Inspector value.
  • Unconnected inputs use the following values:
    • x, y = 0
    • vec = [vec_x, vec_y]
    • flag = false

Available features

  • Variables: x, y, 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

  • vec2(x, y)
  • vec2(x + 1, y - 1)
  • vec + vec2(2, 0)
  • if(flag, vec2(1, 0), vec2(0, 1))

Concrete examples

Example 1: Convert coordinates directly to Vec2

  • Set x to 1
  • Set y to 2
  • expression = vec2(x, y)
value = [1, 2]

Example 2: Add an offset

  • Set x to 1
  • Set y to 2
  • expression = vec2(x + 1, y + 2)
value = [2, 4]

When to use it

  • When you want to reuse vector math across Expression or List expressions
  • When you want to keep two components together, then split them with x(vec) / y(vec) in a later expression

Notes

  • Make sure the expression can ultimately be converted to Vec2.
  • When unsure, explicitly writing vec2(...) is safest.
  • The primary Transform and Path nodes currently have no input that accepts Vec2 directly. Pass the components as separate numbers when needed.
  • && / || and if short-circuit. Reversed clamp bounds are swapped, sign(0) = 0, and % is a non-negative Euclidean remainder. Division or modulo by zero and sqrt of a negative value produce an error.
  • While you type an expression, the incomplete intermediate text is evaluated immediately, so an error may appear temporarily.
Back to Node List
Expression Vec2 — PixPipeline Node Reference