Vec2ScalarOperation
Scale a 2D vector by a plain number
- a
- VEC2
If you're carrying a size or an offset around your graph as a single VEC2 instead of two loose floats, this is the node that scales it - multiply or divide the whole vector by one plain number, in one step, instead of splitting it into components, doing the math twice, and putting it back together. Vec2ScalarOperation is that shortcut.
It's part of ComfyMath, evanspearman's math/logic pack, and it's the natural companion to CM_Vec2BinaryOperation (vector-plus-vector) - this one is specifically for vector-times-number.
How it works
Feed it a (a VEC2, default [0, 0]) and b (a plain FLOAT - the scalar), pick an op: Mul or Div, and it applies that operation to both components of a using b. This is the node you reach for to zoom a size vector by an upscale factor, or shrink an offset proportionally without recomputing X and Y separately.
Worth flagging directly from the node's own definition: b doesn't ship with a default value the way a does - a defaults to [0, 0], but b has no listed default. In practice that means it's worth making sure you've actually set b to something deliberate before running the graph, especially with Div selected - dividing by an unset or zero scalar is the kind of thing that produces infinity or NaN silently rather than an obvious error.
Inputs and outputs
op- Mul or Div.a(VEC2, default[0, 0]) - the vector being scaled.b(FLOAT) - the scalar to multiply or divide by. No default shown - set it explicitly.- Output:
VEC2- the scaled vector.
How to install it
Through ComfyUI Manager: search ComfyMath, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/evanspearman/ComfyMath.git
then restart ComfyUI. No dependencies, no models to fetch - plain Python.
Common issues & troubleshooting
Output is infinity or NaN. Almost certainly a Div with b at or near zero. Since b doesn't have a guaranteed default, double-check what's actually wired into it (or typed into the widget) before trusting the result downstream. ComfyMath's CM_FloatUnaryCondition (IsZero, IsFinite) is a quick way to catch this before it happens rather than after.
The scaled vector looks doubled or halved unexpectedly. Confirm you picked the operation you meant - Mul and Div sit right next to each other in the dropdown, and it's an easy misclick.
Missing node error on workflow load. Install ComfyMath through Manager as above, then reload.
Not sure you need this node at all. Most workflows never touch Vec2 nodes - this shows up specifically when you're building your own coordinate, offset, or tile-size math rather than a standard generation graph.
The pack looks unmaintained. A 2024 community thread noted the author had stepped back from active development. It's plain math with no external dependencies, so there's little here that a ComfyUI update is likely to break.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| op | COMBO | 2 options: Mul, Div | |
| a | VEC2 | 0,0 | — |
| b | FLOAT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| VEC2 | VEC2 | — |