SVG Art Grid Dimensions Calculator
The boring math node that keeps your SVG grids from breaking
- rows
- cols
Every SVG grid layout eventually hits the same wall: you want a grid that fills your canvas, but the moment you hardcode rows and columns the cells come out the wrong shape, or you have a weird strip of dead space on one edge. SVG Art Grid Dimensions Calculator exists to make that number-crunching boring, and that's a good thing - it's one of those helper nodes you don't think about until the grid is broken, and then it's the fix.
What it's for
This is a companion to the ArtGrid family in svg-suite (SVGArtGridV2 and friends). Those nodes build SVG grids, but they need to be told how many rows and columns to use. This node computes them for you from the canvas size, so your grid cells stay close to square and the whole thing fills the frame without overflow.
It's a pure math node - no SVG string in, no SVG string out. You give it dimensions and it hands back two integers.
How it works
Pick a method and it does the obvious thing:
- aspect_ratio (default) - tries every column count between min and max, and picks the one whose resulting grid aspect ratio is closest to your canvas. This is the one you'll normally use.
- fixed_cell_size - divides width and height by target_cell_size (default 64px) to get the grid. Use this when cells must be a specific pixel size.
- min_cells - just returns the minimum count in both dimensions, for big chunky cells.
- max_cells - returns the maximum, for maximum detail at small cell sizes.
The two inputs you'll actually set are width and height of your canvas, plus min_cells / max_cells to bound how coarse or fine the grid is allowed to get (4 to 30 by default). Outputs are rows and cols - two INTs that wire straight into the rows/cols inputs of an ArtGrid node. That's the whole job.
Install
Shared with the rest of svg-suite, so nothing special:
cd ComfyUI/custom_nodes
git clone https://github.com/MushroomFleet/svg-suite
pip install -r requirements.txt
Restart ComfyUI after, or search "svg-suite" in ComfyUI Manager. This node itself only needs torch and math, so it'll work even if some of the heavier tracing dependencies failed to install.
Gotchas
The aspect-ratio method doesn't literally lock cell shape to the canvas - it finds the closest match within your min/max bounds, so a 512×512 canvas with min_cells: 4 and max_cells: 30 will happily land on rows=cols and give you square cells. But if your canvas is, say, 512×384, you'll get an approximation, and that's expected. Set your bounds thoughtfully: a max_cells of 30 with min_cells of 4 is a wide search space, and the result is a compromise.
If you're coming from a raster mindset, don't overthink it. This node doesn't touch quality - it just stops you from eyeballing grid math that's genuinely annoying to do by hand. For a one-off grid you can skip it; for a reusable workflow, wire it in once and never think about rows and columns again.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 51232–8192 | — |
| height | INT | 51232–8192 | — |
| min_cells | INT | 41–100 | Minimum number of cells in either dimension |
| max_cells | INT | 301–100 | Maximum number of cells in either dimension |
| method | COMBO | aspect_ratio | 4 options: aspect_ratio, fixed_cell_size, min_cells, max_cells |
| target_cell_sizeopt | INT | 648–512 | Target size of each cell in pixels (for fixed_cell_size method) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| rows | INT | — |
| cols | INT | — |