Description
Pack supplied rectangular widgets into a cell grid with randomized bounded backtracking and validated nonoverlap placements.
An interface fixture makes content and state explicit so a consumer can test a rendering or interaction. Literal labels, modeled states, and calculated geometry remain separate from what a browser or assistive technology actually displays or announces.
Pack supplied rectangular widgets into a cell grid with randomized bounded backtracking and validated nonoverlap placements.
When to use this tool
Use this generator to create reproducible dashboard widget layout cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.
How to use the tool and how it works
- Supply rows, columns, widgets, allowRotation, maximumSearchNodes in the field shapes below. Set seed when you need an explicit replay.
- Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
- Read placements, occupancy, occupancyJson, exploredPlacements. Use the conventions below. Keep answer-bearing fields separate when presenting an exercise.
Shuffle widget processing order and search delegated empty-rectangle placements on a cell board, optionally allowing quarter turns. Mark occupied cells with original widget index plus one and return the first complete placement, occupancy matrix, and explored-placement count.1
Delegated operations used for this result: grid inventory rectangle fit checker; as json. Their calculation or parsing conventions apply to the corresponding result fields.2, 3
| Input field | Meaning and units | Accepted input |
|---|---|---|
| rows | Rows | Required. Safe integer; minimum 1; maximum 16. |
| columns | Columns | Required. Safe integer; minimum 1; maximum 16. |
| widgets | Widgets | Required. Array of Object; no unknown keys.; minimum items 1; maximum items 12. |
| widgets[].id | Literal identifier used independently of display labels. | Required. Text; minimum UTF-16 length 1; maximum UTF-16 length 64. |
| widgets[].widthCells | Width Cells | Required. Safe integer; minimum 1; maximum 16. |
| widgets[].heightCells | Height Cells | Required. Safe integer; minimum 1; maximum 16. |
| allowRotation | Allow Rotation | Required. Boolean. |
| maximumSearchNodes | Maximum Search Nodes | Required. Safe integer; minimum 1; maximum 20000. |
| seed | Optional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed. | Optional. Safe integer. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| placements | Placements | Required. Array of Object; no unknown keys.; minimum items 1; maximum items 12. |
| placements[].id | Literal identifier used independently of display labels. | Required. Text. |
| placements[].row | Row | Required. Safe integer; minimum 0; maximum 15. |
| placements[].column | Column | Required. Safe integer; minimum 0; maximum 15. |
| placements[].heightCells | Height Cells | Required. Safe integer; minimum 1; maximum 16. |
| placements[].widthCells | Width Cells | Required. Safe integer; minimum 1; maximum 16. |
| occupancy | Occupancy | Required. Array of Array of Safe integer; minimum 0; maximum 12.; minimum items 1; maximum items 16.; minimum items 1; maximum items 16. |
| occupancyJson | Occupancy Json | Required. Text; maximum UTF-16 length 4096. |
| exploredPlacements | Explored Placements | Required. Safe integer; minimum 1; maximum 20000. |
| randomness | Replay source and normalized 32-bit seed, or null seed for an advancing context source. | Required. Object; no unknown keys. |
| randomness.seed | Optional safe-integer replay seed; normalization and precedence are explained below. | Required. Safe integer. or Null. |
| randomness.source | Source | Required. Text; one of "context", "seed". |
An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.
{
"input": {
"rows": 2,
"columns": 2,
"widgets": [
{
"id": "a",
"widthCells": 2,
"heightCells": 1
},
{
"id": "b",
"widthCells": 2,
"heightCells": 1
}
],
"allowRotation": false,
"maximumSearchNodes": 100,
"seed": 42
},
"output": {
"placements": [
{
"id": "a",
"row": 1,
"column": 0,
"heightCells": 1,
"widthCells": 2
},
{
"id": "b",
"row": 0,
"column": 0,
"heightCells": 1,
"widthCells": 2
}
],
"occupancy": [
[
2,
2
],
[
1,
1
]
],
"occupancyJson": "[[2,2],[1,1]]",
"exploredPlacements": 2,
"randomness": {
"seed": 42,
"source": "seed"
}
}
} Limitations and assumptions
- Zero cells are empty. Total area fitting does not prove the shapes fit, and maximumSearchNodes can terminate search. This is discrete nonoverlapping layout rather than CSS rendering or an optimal arrangement.
- A replay requires the same complete input and implementation. The stated sampling convention applies within its eligible space. A finite draw does not exhaust all possible outputs; repeats remain possible unless a distinct-selection rule is explicit.
- The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.
Alternative or Complementary methods
For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.
References
Similar or alternative tools
- Random CSS Grid Layout Preset Generator
Generate a definite-width grid preset with delegated fixed-track fit counts and initial fr shares, excluding intrinsic browser sizing.
- Random Flex Layout Stress Case Generator
Generate flex bases and factors with delegated initial grow or shrink expectations before min-size freezing.