Nodes/ComfyUI-Apt_Preset/create_lineGradient
ComfyUI Node

create_lineGradient

A two-color linear gradient, plus its mask, at any angle

By cardenluo·Created 2 years ago·Updated 17 days ago· 309
create_lineGradient
    • IMAGE
    • MASK
    width512
    height512
    gradient_distance1.00
    linear_transition0.50
    orientation0
    start_color_hex#FFFFFF
    end_color_hex#000000

    Sometimes you don't need a whole gradient-map generator - you just need a clean two-color linear blend at a specific angle, and its matching mask so you can use the same gradient as a blend weight elsewhere. create_lineGradient does exactly that, nothing more.

    What it is and why you'd reach for it

    This lives in ComfyUI-Apt_Preset's image-effect utilities, and it's a genuinely simple procedural generator: two hex colors, a size, an angle, and a couple of shaping controls. Reach for it when you need a gradient background, a gradient overlay for compositing, or - via the matching MASK output - a smooth blend weight for feathering one image into another at a controlled angle, rather than the default horizontal or vertical gradients most tools give you out of the box.

    How it works

    width/height set the canvas size (64–4096). start_color_hex and end_color_hex are the two ends of the blend. orientation (0–360°) rotates the gradient direction - 0 and 180 both run roughly horizontal but reversed, 90/270 vertical, anything else at an angle. gradient_distance (0–2, default 1) and linear_transition (0–1, default 0.5) both shape how hard or soft the transition band is: push gradient_distance toward 0 for a tighter, more compressed blend and toward 2 for a longer, more stretched-out one, and use linear_transition to fine-tune where the 50/50 point of the blend sits. The fastest way to understand exactly how these two interact is to run the node once at the defaults and nudge one at a time - the effect is visual and immediate.

    Inputs and outputs that matter

    • width / height (64–4096, default 512) - canvas size.
    • orientation (0–360, default 0) - the gradient's angle.
    • start_color_hex / end_color_hex (default #FFFFFF / #000000) - the two blend colors.
    • gradient_distance (0–2, default 1) and linear_transition (0–1, default 0.5) - shape the transition's tightness and midpoint.

    Outputs: IMAGE, the rendered gradient in full color, and MASK, the same gradient rendered as a mask - useful as a feathered blend weight for compositing two images together along the same angle, or as an input to any of Apt_Preset's other mask-compositing nodes.

    Installing it

    Through ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
    

    Run install.bat on Windows for dependencies; on Linux/Mac install the requirements yourself, since no bundled script covers those platforms. No model downloads needed - this is procedural rendering, no weights involved.

    Common issues

    If your gradient looks like a hard edge instead of a smooth blend, that's almost always gradient_distance pushed too low - try nudging it back toward 1 or above before assuming something's broken. Conversely, if the transition looks washed out and barely visible, push it the other direction.

    The default colors are pure white to pure black, which is easy to forget if you're expecting a specific color pair by default - set both hex fields explicitly rather than relying on defaults if you need a particular look.

    As with the rest of ComfyUI-Apt_Preset: it's a large, actively-updated pack, and at least one user has reported an IMPORT FAILED error at ComfyUI startup after installing it. Check the console log if this node doesn't appear after install.

    CategoryApt_Preset/imgEffect

    Inputs (7)

    NameTypeDefaultDescription
    widthINT51264–4096
    heightINT51264–4096
    gradient_distanceFLOAT1.000–2
    linear_transitionFLOAT0.500–1
    orientationINT00–360
    start_color_hexSTRING#FFFFFF
    end_color_hexSTRING#000000

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK