Rect to Ints
A rectangle as integers, rounded the way you choose
- tinyrect
- x
- y
- w
- h
- x2
- y2
- center_x
- center_y
Rect to Ints converts a TINYRECT into integer coordinates - and unlike the float version, it lets you choose whether those integers come from rounding or truncation. When your rectangle has to feed a pixel-based node that can't stand fractional coordinates, this is the clean-up step.
Why you'd reach for it
Rectangles in TinyBee are float-based, but the real world of image ops is integer-based: crops, sampling boxes, mask sizes - most want whole pixels. Feed a 3.7-wide rect into the wrong consumer and you're in floating-point limbo. This node snapshots the box to integers so downstream nodes see clean pixel coordinates, and the roundFloats toggle decides how it snaps.
How it works
The rect's x, y, w, h get converted with either int() (truncation toward zero - the default) or Python's round() when roundFloats is on. Then the derived edges are computed from the converted values: x2 = x + w, y2 = y + h, and in current builds also center_x = x + w/2 and center_y = y + h/2, all snapped the same way. The important detail is that the right/bottom edges are built from the already-integerized x/y/w/h - so the rectangle stays consistent (no off-by-one drift between w and x2).
The inputs that matter
- tinyrect - the rectangle to convert.
- roundFloats - off by default (truncate). On = round to nearest.
Outputs:
- x / y / w / h - integerized box.
- x2 / y2 - bottom-right corner (and center_x / center_y on current builds).
Installing it
TinyBee pack: ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee
Under 🐝TinyBee/Rectangles. Stdlib only.
Common issues
The truncate-vs-round choice matters more than it looks. Truncation always rounds toward zero, so a 3.9 width becomes 3 - if you're cropping, you can shave a pixel off the edge you didn't intend. For crops specifically, rounding (roundFloats on) is usually the safer pick. And note x2/y2 are computed from the truncated values, not from the original floats - that's deliberate consistency, but it means a 0.5-pixel error in the source rect can propagate. When precision matters, do your rect math in floats first, then convert once at the boundary.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tinyrect | TINYRECT | — | |
| roundFloats | BOOLEAN | false | — |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| x | INT | — |
| y | INT | — |
| w | INT | — |
| h | INT | — |
| x2 | INT | — |
| y2 | INT | — |
| center_x | INT | — |
| center_y | INT | — |