Create Gradient From Coords(CreateGradientFromCoords)
This node receives a JSON string containing the start and end point coordinates, and calculates the color value for each pixel based on the direction of the line defined by these two points.
Create Gradient From Coords
The Create Gradient From Coords node receives a JSON string containing start and end coordinates and calculates the color value for each pixel based on the direction of the line defined by these two points.
The Create Gradient From Coords node is an image generation tool that can create a linear gradient image on a specified canvas size based on two coordinate points provided by the user. Its core function is to transform abstract coordinate data into a visual color transition effect.
Node Function
This node receives a JSON string containing start and end coordinates and calculates the color value for each pixel based on the direction of the line defined by these two points. It supports defining the gradient's start and end colors via color names or hexadecimal codes and controls the intensity or speed of the gradient transition through a multiplier factor, ultimately outputting a standard three-channel RGB image.
Node Parameter Description - Create Gradient From Coords
Control Parameters (Parameters)
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
coordinates | STRING | Yes | - | - | coordinates (input parameter): A JSON string containing the start and end coordinates used to define the gradient's directional line. Format example: [{"x":10, "y":10}, {"x":500, "y":500}]. |
frame_width | INT | Yes | 512 | 16 - 4096 (step: 1) | frame_width (input parameter): The width of the generated gradient image, ranging from 16 to 4096 with a step of 1. |
frame_height | INT | Yes | 512 | 16 - 4096 (step: 1) | frame_height (input parameter): The height of the generated gradient image, ranging from 16 to 4096 with a step of 1. |
start_color | STRING | Yes | white | - | start_color (input parameter): A string defining the gradient's starting color, e.g., "white" or "#FF0000". |
end_color | STRING | Yes | black | - | end_color (input parameter): A string defining the gradient's ending color, e.g., "black" or "#0000FF". |
multiplier | FLOAT | Yes | 1.0 | 0.01 - 100.0 (step: 0.01) | multiplier (input parameter): A multiplier factor controlling the intensity of the gradient transition, ranging from 0.01 to 100.0 with a step of 0.01. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| image | IMAGE | image (output parameter): The gradient image generated based on the input coordinates and colors. |
Use Cases
This node is highly useful for creating background images requiring specific directional gradients, providing dynamic masks for other image processing nodes (such as mask or blend nodes), or generating auxiliary images for controlling other effects (like lighting or depth). Users can first generate coordinates via other nodes (such as pose detection or region selection) and then connect them to this node to create gradients that match the direction of scene elements.
Notes
Ensure the input coordinate string format is correct and that the coordinate values are within the canvas dimensions; otherwise, it may lead to gradient calculation errors or abnormal image display. Color names should be common English names or valid hexadecimal codes.
Create Gradient From Coords Node Source Code Link
The Create Gradient From Coords node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.