Gradient To Float
Sample a gradient image into a numeric curve
- image
- float_x
- float_y
Every so often you have a gradient - a drawn curve, an exported image, whatever KJNodes' own "Create Gradient From Coords" node handed you - and what you actually need next is a plain list of numbers to drive a schedule with: zoom over time, an animated strength value, a pan path. GradientToFloat runs that conversion in reverse: hand it an image with a gradient in it, and it samples that gradient at a fixed number of steps and hands back the underlying float values, split into x and y curves.
It's a small, honest utility, and it pairs naturally with the pack's coordinate-to-gradient node going the other direction - together they let you move between "a visual curve I can eyeball" and "a list of numbers a scheduler node wants" without hand-typing either one.
How it works
The node walks across the image steps times, sampling brightness (or position, depending on how the gradient was drawn) at each step, and returns two separate float lists - one for the horizontal axis, one for the vertical. If your gradient was built to encode a single 1D curve, you'll typically only care about one of the two outputs; if it encodes a 2D path, you get both axes back independently.
The inputs and outputs that matter
image- the gradient you're sampling. This has to actually contain a gradient for the output to mean anything; a flat or noisy image will sample as flat or noisy numbers.steps(default 10, minimum 2, up to 10000) - how finely you sample the gradient. This is your resolution knob - more steps means a smoother curve but a longer float list to manage downstream.
Two outputs: float_x and float_y, the sampled curves along each axis. Wire whichever one you actually need into your schedule-consuming node - an amplitude driver, a batch of parameter values, whatever's on the other end.
How to install it
Via ComfyUI Manager: search "KJNodes for ComfyUI," install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt
then restart ComfyUI. Nothing extra needed - it's image sampling, no models involved.
Common issues & troubleshooting
The curve looks stepped or blocky. Bump steps up - a low step count under-samples a smooth gradient and you'll get a jagged approximation instead of the intended smooth curve.
One of the two outputs is just flat/zero. That's expected if your source gradient only varies along one axis - a horizontal gradient will produce a meaningful float_x and a flat float_y, and vice versa. Don't assume both outputs are always useful; check which axis your specific gradient actually encodes.
You can't find documentation for how "Create Gradient From Coords" (the companion node that builds these gradients) expects its input formatted. That's a real, known gap - even the author's README leans entirely on tooltips rather than written docs for the pack's more obscure corners, and this pairing is one of them. Expect to experiment with a simple test gradient first rather than find a worked example online.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| steps | INT | 102–10000 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float_x | FLOAT | — |
| float_y | FLOAT | — |