RC Gradient Generator
Generating gradients with JSON, because of course
- reference_image
- IMAGE
There are a hundred ways to make a gradient in ComfyUI, and most of them are either fixed-size or painful to tune. RC Gradient Generator is the pack's answer: a generator that creates gradient images with multiple color stops, per-stop transparency, and four gradient types - linear, radial, angular, and reflected - computed with lookup tables so it's fast even at large sizes.
The catch, and you'll want to know this up front: your gradient is defined as a JSON string. It's not hard, but it's the thing that trips everyone up, so let's get it out of the way.
How it works
The gradient_data field is a JSON object with a stops array. Each stop has a position (0.0 to 1.0 along the gradient) and an RGBA color (each 0–255). The default value shows the pattern:
{"stops": [
{"position": 0.0, "color": [0, 0, 0, 255]},
{"position": 1.0, "color": [255, 255, 255, 255]}
]}
That's a black-to-white linear gradient. Add a third stop at position 0.5 with color: [255, 0, 0, 255] and you get black→red→white. The fourth value in the color array is alpha, so [255, 255, 255, 0] gives you a transparent stop - which is how you build gradients that fade out instead of ending in a hard color.
The rest is placement:
- gradient_type - linear, radial, angular, or reflected.
- angle - rotation, −180 to 180.
- size_mode -
custom(use width/height) orfrom_image(match an optionalreference_image). - center_x / center_y - gradient center as 0–1 fractions of the canvas, for radial/angular types.
- scale - zoom the gradient 0.1–5×.
Output is a single IMAGE tensor. The alpha channel survives, so you can composite the result over a background with the pack's RC Mask Apply or RC Image Compositor.
How to install it
Ships with the RC Image Compositor pack:
cd ComfyUI/custom_nodes
git clone https://github.com/kj863257/ComfyUI_RC_Image_Compositor
cd ComfyUI_RC_Image_Compositor
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager by searching "RC Image Compositor". Requirements: pillow, numpy, opencv-python.
Common issues
JSON syntax is the whole game here. A missing comma, an unquoted key, or a color value outside 0–255 and the node errors out. If you're pasting multi-stop gradients, keep a text editor open with the structure above as a template - this is the most error-prone node in the pack for a reason.
Second, remember positions must be within 0.0–1.0 and ideally ascending. Stops outside that range get clamped or produce odd wraps, especially with reflected type.
Third, don't reach for this when you just want a quick background fill. For flat fills, a Constant node is simpler. Gradients earn their keep in three places: transparent fade layers for compositing, radial vignettes to darken corners, and gradient-map-style grading when combined with the pack's gradient tools. If you want preset colors (Sepia, Fire Heat, Thermal, Film Noir), the pack's RC Gradient Map has them built in - that's the lazier path.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| gradient_data | STRING | {"stops": [{"position": 0.0, "color": [0, 0, 0, 255]}, {"position": 1.0, "color": [255, 255, 255, 255]}]} | — |
| gradient_type | COMBO | linear | 4 options: linear, radial, angular, reflected |
| angle | FLOAT | 0-180–180 | — |
| size_mode | COMBO | custom | 2 options: from_image, custom |
| width | INT | 51264–8192 | — |
| height | INT | 51264–8192 | — |
| center_x | FLOAT | 0.500–1 | — |
| center_y | FLOAT | 0.500–1 | — |
| scale | FLOAT | 1.00.1–5 | — |
| reference_imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |