Nodes/ComfyUI-WBLESS/Baseline Alignment (X)
ComfyUI Node

Baseline Alignment (X)

Align a layer's right edge to a baseline — the X math done for you

By LaoMaoBoss·Created about a year ago·Updated 6 days ago· 0
Baseline Alignment (X)
  • width_a
  • width_b
  • x_percent
baseline_percent80.00

Positioning in ComfyUI is usually done in percentages: "put this image at 30% from the left." But percentage positioning is blind - it centers the layer's box, so a wide layer and a narrow layer end up sitting at different visual positions even at the same percentage. Baseline Alignment (X) fixes that by computing the position you actually want: it tells you the X percentage where a layer's center should sit so that the layer's right edge lands exactly on a baseline position you choose within a reference width.

If that sounds like layout math you've done by hand in a spreadsheet, that's the point - this node does it live, inside the graph, and it recomputes every run. It's one half of the pack's baseline pair: the Y version handles vertical alignment, this one handles horizontal.

How it works

Three inputs, one output:

  • width_a - the width of the layer you're positioning.
  • width_b - the reference width (your canvas, or the space you're aligning within).
  • baseline_percent - where the baseline sits in width_b, as a percentage. Default 80.

The node computes how far the layer's center is from its right edge as a percentage of width_b (width_a / 2 / width_b × 100), then subtracts that from baseline_percent. The result - x_percent - is the X position to feed into a positioning node (like the pack's Image Mask Blend x_percent, or any node that places by percentage) so the layer's right edge sits exactly on the baseline. Wire width_a from Get Image Size or a mask's size and the whole thing tracks your content automatically.

Install

Part of ComfyUI-WBLESS:

cd ComfyUI/custom_nodes
git clone https://github.com/LaoMaoBoss/ComfyUI-WBLESS

restart ComfyUI, or install "ComfyUI-WBLESS" via ComfyUI Manager. No dependencies, no models.

Troubleshooting

The math assumes width_a is smaller than width_b in the normal case, and the result can go negative or past 100 when it isn't - that's fine and intentional (the source notes the output is deliberately unclamped; a huge layer may need a negative position to align its right edge to the baseline). If your layer is aligned but on the wrong side, remember this aligns the right edge - the Y node in this pair does the same for the bottom edge, and there's no built-in left/top mode, so flip the math yourself if you need the mirror image. It's a tiny node with a narrow job, but it's exactly the one you reach for when "percent positioning" keeps giving you misaligned layers.

Category🌈WBLESS

Inputs (3)

NameTypeDefaultDescription
width_a*
width_b*
baseline_percentFLOAT80.00

Outputs (1)

NameTypeDescription
x_percentFLOAT