Create Shape Mask(CreateShapeMask)
This node generates black-and-white mask images by programmatically drawing geometric shapes on a canvas of specified dimensions.
Create Shape Mask
The Create Shape Mask node generates black-and-white mask images by programmatically drawing geometric shapes on a canvas of specified dimensions.
The Create Shape Mask node is used to generate masks of specified shapes within ComfyUI. It allows users to create circular, square, or triangular masks and can batch-generate a series of masks with varying sizes, providing a flexible selection tool for image processing workflows.
Node Functionality
This node generates black-and-white mask images by programmatically drawing geometric shapes on a canvas of specified dimensions. It supports generating a single mask or a batch sequence of masks, with independent control over the shape, position, and size of each mask. Its core mechanism involves adjusting the "grow" parameter to uniformly scale the shape by a set value in each frame of the sequence, thereby creating a dynamically changing mask animation effect.
Node Parameter Description - Create Shape Mask
Control Parameters
| Parameter Name | Data Type | Required | Default Value | Range/Options | Description |
|---|---|---|---|---|---|
shape | COMBO | Yes | circle | "circle", "square", "triangle" | The geometric shape to draw: circle, square (square), or triangle (triangle). |
frames | INT | Yes | 1 | 1 - 4096 (step: 1) | Specifies the number of masks to generate (batch size). The value range is 1 to 4096. |
location_x | INT | Yes | 256 | 0 - 4096 (step: 1) | Sets the horizontal (X-axis) coordinate of the shape's center point on the canvas. The value range is 0 to 4096. |
location_y | INT | Yes | 256 | 0 - 4096 (step: 1) | Sets the vertical (Y-axis) coordinate of the shape's center point on the canvas. The value range is 0 to 4096. |
grow | INT | Yes | 0 | -512 - 512 (step: 1) | Defines the size change of the shape in each frame. A positive value enlarges the shape frame by frame, while a negative value shrinks it. The value range is -512 to 512. |
frame_width | INT | Yes | 512 | 16 - 4096 (step: 1) | Sets the width of the generated mask canvas. The value range is 16 to 4096. |
frame_height | INT | Yes | 512 | 16 - 4096 (step: 1) | Sets the height of the generated mask canvas. The value range is 16 to 4096. |
shape_width | INT | Yes | 128 | 8 - 4096 (step: 1) | Sets the initial width of the shape. The value range is 8 to 4096. |
shape_height | INT | Yes | 128 | 8 - 4096 (step: 1) | Sets the initial height of the shape. The value range is 8 to 4096. |
Output
| Parameter Name | Data Type | Description |
|---|---|---|
| mask | MASK | The output original mask, where the white area represents the shape selection. |
| mask_inverted | MASK | The output inverted mask, where the black and white areas are reversed compared to the original mask. |
Usage Scenarios
This node is very useful in workflows requiring local adjustments or special effects application. For example, when creating an animation of a circular glow gradually enlarging, you can connect the mask sequence generated by this node to a "VAE Encode" node to control color or brightness changes in a specific area. Alternatively, the generated square mask can be fed into an "Image Composite" node for replacing or blending a rectangular area of an image.
Notes
When using this node, note that all position coordinates (location_x, location_y) are based on the center point of the shape. The generated mask size is constrained by both the canvas (frame_width, frame_height) and the shape's own dimensions (shape_width, shape_height), ensuring the shape does not exceed the canvas boundaries.
Create Shape Mask Node Source Code Link
The Create Shape Mask node is from the ComfyUI-KJNodes node package.
Comments
Sign in with GitHub to join the discussion.