feat: normalize tabsize formula and default across all puzzle types - #94
Conversation
Standardize tabsize conversion to /100 everywhere (rectangular and legacy hex used /200) and set new default to 6. This ensures consistent tab proportions across all puzzle types — the same tabsize value now produces the same tab-to-edge ratio regardless of puzzle type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR standardizes how tabsize is interpreted across all puzzle generators by normalizing the underlying formula and aligning defaults/documentation so tab proportions are consistent across puzzle types.
Changes:
- Normalize
tabsizescaling to use/ 100consistently (including rectangular + legacy hex paths). - Change the default
tabsizeto6across generators, config, and ggplot geoms/stats. - Update Quarto + roxygen docs to reflect new defaults/semantics and reorganize some gallery examples.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| quarto/index.qmd | Update landing page copy and example annotations for new defaults / puzzle count. |
| quarto/getting-started.qmd | Update getting-started parameter equivalence table for new default tabsize. |
| quarto/gallery/voronoi.qmd | Update Voronoi gallery default tabsize and reorder example tabs. |
| quarto/gallery/snic.qmd | Update SNIC gallery default tabsize. |
| quarto/gallery/rectangular.qmd | Update rectangular gallery default tabsize and reorder example tabs. |
| quarto/gallery/random.qmd | Update random gallery default tabsize. |
| quarto/gallery/hexagonal.qmd | Update hex gallery default tabsize. |
| quarto/gallery/concentric.qmd | Update concentric gallery default tabsize and reorder example tabs. |
| quarto/api/ggpuzzle.qmd | Update ggpuzzle API tables to show new tabsize default. |
| quarto/api/generate-puzzle.qmd | Update generate_puzzle API docs for new tabsize default + semantics. |
| inst/config.yml | Update configuration “source of truth” default tabsize to 6 (incl. development). |
| R/unified_piece_generation.R | Update internal unified generator default tabsize. |
| R/tessellation_edge_generation.R | Update tessellation edge generator defaults used by Voronoi/random/SNIC. |
| R/svg_utils.R | Update enhanced SVG helper default tabsize. |
| R/stat_puzzle.R | Update ggplot2 stat default tabsize. |
| R/snic_puzzle.R | Update SNIC internal generator default tabsize. |
| R/rectangular_puzzle.R | Normalize rectangular tabsize formula (/100) and update defaults. |
| R/puzzle_core_clean.R | Update core generator default tabsize. |
| R/main_generator.R | Update orchestration helper default tabsize. |
| R/jigsawR_clean.R | Update main generate_puzzle() default tabsize. |
| R/individual_pieces_final.R | Update individual piece utilities default tabsize. |
| R/individual_pieces.R | Update individual piece utilities default tabsize. |
| R/hexagonal_separation.R | Update hex separation helpers default tabsize. |
| R/hexagonal_puzzle.R | Normalize hex tabsize formula (/100) and update defaults/examples. |
| R/hexagonal_piece_extraction.R | Update separated-hex helper default tabsize. |
| R/hexagonal_individual_pieces.R | Update hex individual pieces default tabsize. |
| R/hexagonal_edge_generation_fixed.R | Update hex edge-map pipeline defaults. |
| R/hexagonal_bezier_generation.R | Update hex bezier pipeline defaults and examples. |
| R/geom_puzzle.R | Update ggplot2 geom defaults + roxygen param text for tabsize. |
| R/config_utils.R | Update fallback config defaults for styling tabsize. |
| R/concentric_individual_pieces.R | Update concentric individual pieces default tabsize. |
| R/concentric_edge_generation.R | Update concentric edge-map pipeline defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| generate_puzzle <- function(type = "rectangular", | ||
| grid = c(3, 4), | ||
| size = c(400, 300), | ||
| seed = NULL, | ||
| tabsize = 10, | ||
| tabsize = 6, | ||
| jitter = 2, |
There was a problem hiding this comment.
generate_puzzle() now defaults tabsize to 6, but generate_puzzle_batch()'s helper still assigns var$tabsize <- 20 when missing, causing inconsistent defaults between single and batch generation. Align the batch default with the new global default (and ideally reuse formals(generate_puzzle)$tabsize / config).
| #' min_tab_size = 10, max_tab_size = 30) | ||
| #' } | ||
| generate_tessellation_edge <- function(v1, v2, seed, edge_id, | ||
| tabsize = 20, jitter = 4, | ||
| tabsize = 6, jitter = 4, | ||
| tab_direction = 1, |
There was a problem hiding this comment.
The roxygen still states @param tabsize default is 20, but the function signature now defaults to 6. Update the parameter documentation so users see the correct default (and range/meaning if applicable).
| #' @return List containing piece paths and metadata | ||
| generate_concentric_individual_pieces <- function(rings = 3, seed = NULL, | ||
| diameter = 240, | ||
| tabsize = 27, jitter = 5, | ||
| tabsize = 6, jitter = 5, | ||
| center_shape = "hexagon", |
There was a problem hiding this comment.
The roxygen above this function still says tabsize default is 27 (and range 10-40), but the function now defaults to 6. Update the @param tabsize documentation to match the new normalized default/semantics.
| #' @param xn Number of columns | ||
| #' @param yn Number of rows | ||
| #' @return List containing SVG path data | ||
| generate_jigsaw_svg <- function(seed = NULL, tabsize = 20, jitter = 4, | ||
| generate_jigsaw_svg <- function(seed = NULL, tabsize = 6, jitter = 4, | ||
| width = 300, height = 200, |
There was a problem hiding this comment.
The roxygen for generate_jigsaw_svg() still documents tabsize as "(10-30)" and jitter as "(0-13)", which no longer matches the new normalized defaults/semantics (tabsize = 6, and tabsize described elsewhere as 0-100). Please update these parameter docs to stay consistent.
| hex_puzzle <- generate_hex_jigsaw_svg( | ||
| seed = 1234, | ||
| tabsize = 27, # 27% (JS default) | ||
| tabsize = 6, # 27% (JS default) |
There was a problem hiding this comment.
In the example block, the inline comment still says "27% (JS default)" but tabsize is now set to 6. This is misleading—update the comment (and any mention of the old default) to match the new normalized default/semantics.
| tabsize = 6, # 27% (JS default) | |
| tabsize = 6, # Normalized tab size (equivalent to 27% in original JS) |
| | `seed` | integer | random | Random seed for reproducibility | | ||
| | `offset` | numeric | 0 (mm) | Piece separation distance | | ||
| | `tabsize` | numeric | 10 (%) | Tab size as percentage of piece width | | ||
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | |
There was a problem hiding this comment.
The parameter table still describes tabsize as a percentage of piece width. Tab sizing is based on edge length; updating this wording will better match the normalized tabsize semantics across puzzle types.
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of edge length | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | ||
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage | |
There was a problem hiding this comment.
The parameter table still describes tabsize as a percentage of piece width, which is unclear for irregular random pieces. Since tab sizing is based on edge length, update the description accordingly.
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | |
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage | | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of edge length | | |
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage of tab size | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | ||
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage | |
There was a problem hiding this comment.
The parameter table still describes tabsize as a percentage of piece width, which is not well-defined for SNIC superpixel shapes. Since tab sizing is based on edge length, update the description accordingly.
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | |
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage | | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of local edge length | | |
| | `jitter` | numeric | 2 (%) | Randomness in tab shape as percentage of tab size (based on edge length) | |
| #' @return List containing piece paths and metadata | ||
| generate_hexagonal_individual_pieces <- function(rings = 3, seed = NULL, | ||
| diameter = 240, | ||
| tabsize = 27, jitter = 5, | ||
| tabsize = 6, jitter = 5, | ||
| output_dir = "output", |
There was a problem hiding this comment.
The roxygen above this function still says tabsize default is 27 (and range 10-40), but the function now defaults to 6. Update the @param tabsize documentation to match the new normalized default/semantics.
| | `seed` | integer | random | Random seed for reproducibility | | ||
| | `offset` | numeric | 0 (mm) | Piece separation distance | | ||
| | `tabsize` | numeric | 10 (%) | Tab size as percentage of piece width | | ||
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | |
There was a problem hiding this comment.
The parameter table still describes tabsize as a percentage of piece width, which is not well-defined for Voronoi cells. Since tab sizing is based on edge length, update the description accordingly.
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of piece width | | |
| | `tabsize` | numeric | 6 (%) | Tab size as percentage of edge length | |
Fix hardcoded fallback values (jigsawR_clean.R, stat_puzzle.R, main_generator.R), remove dead special-case logic in individual_pieces_final.R, update all remaining roxygen @PARAM tabsize docs to "(0-100). Default: 6.", fix stale hex comment, and correct quarto wording from "piece width" to "edge length". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
tabsize / 200while all other types (concentric, voronoi, random, snic) usedtabsize / 100. Now all types use/ 100.tabsize = 6: Produces ~18% tab-to-edge ratio across all puzzle types — consistent, proportional, and no overlap on short irregular edges.@paramdescriptions, quarto gallery parameter tables, and API reference pages all reflect the new default and semantics.Visual impact
10/200)6/100)10/100)6/100)10/100)6/100)10/100)6/100)10/100)6/100)10/100)6/100)Files changed
inst/config.yml(source of truth)Test plan
devtools::test()— 2064 pass, 3 pre-existing failures (unrelated: theme_puzzle transparent default, snic platform-specific)🤖 Generated with Claude Code