Nodes/ComfyUI-Purz/Gradient Pattern (Purz)
ComfyUI Node

Gradient Pattern (Purz)

Clean backgrounds from two hex codes

By purzbeats·Created about a year ago·Updated 3 months ago· 24
Gradient Pattern (Purz)
    • image
    width512
    height512
    gradient_typelinear
    directionhorizontal
    color1#000000
    color2#FFFFFF
    batch_size1

    Every workflow needs a gradient at some point - a background behind a subject, a subtle backdrop for img2img, or just a smooth fill to composite something onto. PurzGradientPattern is the node that generates one from two hex colors, with a choice of linear, radial, diagonal, or corner layouts. Two colors in, one smooth IMAGE out, done.

    It's from ComfyUI-Purz, the utility pack by PurzBeats (a Comfy Org staffer). The gradient and its pattern siblings (checkerboard, grid, stripes) are the pack's "generate from nothing" nodes - no image input required, which makes them great for bootstrapping a workflow.

    How it works

    Pure Pillow drawing. It creates a canvas at your width×height, then fills it by interpolating between color1 and color2 according to the gradient_type and direction. Since it's drawing, not rendering, the output is smooth with no banding at any resolution - gradients are one of the few things Pillow's ImageDraw does better than a naive per-pixel loop.

    The layout options are where the character comes from:

    • gradient_type - linear, radial, diagonal, or corner. Linear is the classic left-to-right (or up-to-down) wash; radial fades outward from a center point; diagonal runs corner to corner; corner is a two-axis fade.
    • direction - only applies to linear gradients: horizontal, vertical, and the two diagonal directions. Pick which way color1 flows into color2.

    The inputs that matter

    • width / height - canvas size, 64–4096.
    • gradient_type - linear, radial, diagonal, corner.
    • direction - for linear: horizontal, vertical, diagonal_right, diagonal_left.
    • color1 / color2 - hex colors, e.g. #0f0c29#302b63 for a nice deep purple-to-blue backdrop. Defaults are black → white.
    • batch_size - 1–16, identical frames if you need a batch.

    Output is image, an IMAGE tensor at exactly your requested size, ready to composite, save, or feed into img2img.

    Installing it

    ComfyUI Manager - search ComfyUI-Purz - or:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/purzbeats/ComfyUI-Purz.git
    cd ComfyUI-Purz
    pip install -r requirements.txt
    

    Restart ComfyUI. Requirements are OpenCV, Pillow, torch, numpy - nothing extra to download, no models.

    Where people get burned

    The direction parameter silently does nothing for radial, diagonal, and corner gradient types - it only shapes linear gradients. It's easy to tweak direction on a radial and wonder why nothing changes; that's expected, not a bug. Also, if you're using the gradient as a background to composite on, remember it's an opaque RGB image - there's no transparency option here, so you'll need an alpha channel node if you want a see-through backdrop. Other than those two, it's about as frictionless as a node gets.

    CategoryPurz/Patterns/Basic

    Inputs (7)

    NameTypeDefaultDescription
    widthINT51264–4096
    heightINT51264–4096
    gradient_typeCOMBOlinear4 options: linear, radial, diagonal, corner
    directionCOMBOhorizontal2 options: horizontal, vertical
    color1STRING#000000
    color2STRING#FFFFFF
    batch_sizeINT11–16

    Outputs (1)

    NameTypeDescription
    imageIMAGE