Create Shape Mask On Path
Animated shape masks that move along a path
- mask
- mask_inverted
This one is for animation. CreateShapeMaskOnPath draws a shape - a circle, square, or triangle - and generates a whole batch of masks with that shape placed at a sequence of coordinates. Feed it a path (a list of positions, one per frame) and you get a mask that moves: the shape traveling across the frame over time. That's the raw material for masked video animation - think a spotlight tracking a subject, a region of motion guidance for AnimateDiff or Wan, or an animated matte you drive procedurally instead of painting frame by frame.
How it works
You give it a list of center coordinates. For each coordinate it renders the chosen shape at that spot on a blank frame of your specified size, and stacks all those frames into a batch of masks. Because the positions change from frame to frame, the shape appears to glide along the path when the batch is played back as video. The coordinates usually come from a spline or path-editor node upstream, so you draw the motion once and this node turns it into a frame-by-frame mask sequence.
The inputs that matter
- shape -
circle,square, ortriangle. The mask's form. - coordinates - a string of center positions, one per frame. This is the path. Each entry is where the shape's center sits on that frame. Pipe this from a coordinate/spline node rather than typing it by hand.
- frame_width / frame_height - the size of each mask frame. Match this to the resolution of the video you're masking.
- shape_width / shape_height - how big the shape is. These are the shape's dimensions, not the frame's.
- size_multiplier (optional) - a float (or list of floats) that scales the shape, and because it can be a list, the shape can grow or shrink over the sequence - a circle that swells as it moves, say.
Two outputs: mask and mask_inverted. The inverted one saves you a separate invert node when you need the outside of the shape rather than the inside.
Where it fits
Procedural animated masking. Anywhere you want a region that changes position over a video: guiding where motion happens, isolating a moving subject for a per-region effect, building animated transitions, or feeding a controllable matte into a video model. Kijai builds a lot of the community's video tooling, and nodes like this are the plumbing that makes masked, path-driven video effects possible without hand-animating every frame.
Installing KJNodes
In ComfyUI Manager, search "KJNodes for ComfyUI" in the Custom Nodes Manager, install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), then restart. No models needed.
Gotchas
The coordinates format is where people stumble. It expects a properly structured list of points, which is why it's meant to be driven by an upstream spline/coordinate node rather than typed in raw - get the format wrong and you'll get an empty or single-frame mask. If your "animation" isn't animating, check that you're actually supplying multiple coordinates, one per frame, and that the count lines up with your video's frame count.
Also line up frame_width/frame_height with the resolution of whatever you're compositing against. A mask batch at the wrong size won't register against your video frames, and you'll spend ten minutes wondering why the effect isn't landing where the shape clearly is.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| shape | COMBO | circle | 3 options: circle, square, triangle |
| coordinates | STRING | — | |
| frame_width | INT | 51216–4096 | — |
| frame_height | INT | 51216–4096 | — |
| shape_width | INT | 1288–4096 | — |
| shape_height | INT | 1288–4096 | — |
| size_multiplieropt | FLOAT | 1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |
| mask_inverted | MASK | — |