视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
generate-puzzle【文档与办公】Generate jigsaw puzzles via generate_puzzle() or geom_puzzle_*() with parameter validation against inst/config.yml. Supports rectangular, hexagonal, concentric, voronoi, and snic puzzle types with configurable grid, size, seed, offset, and layout parameters. Use when creating puzzle SVG files for a specific type and configuration, testing generation …
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Make jigsaw puzzles with jigsawR package unified API.
"rectangular", "hexagonal", "concentric", "voronoi", "random", "snic")c(cols, rows) or c(rings))"grid" or "repel" for rectangular)R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
"$R_EXE" -e "cat(yaml::yaml.load_file('inst/config.yml')[['{TYPE}']]$grid$max)"
Or read inst/config.yml direct to check valid ranges for chosen type.
Got: Min/max values for grid, size, tabsize, other parameters known for chosen puzzle type.
If fail: config.yml missing or type key absent? Check in jigsawR project root + package built at least once.
Map user request to valid generate_puzzle() args:
| Type | grid | size | Extra params |
|---|---|---|---|
| rectangular | c(cols, rows) | c(width, height) mm | offset, layout, tabsize |
| hexagonal | c(rings) | c(diameter) mm | do_warp, do_trunc, tabsize |
| concentric | c(rings) | c(diameter) mm | center_shape, tabsize |
| voronoi | c(cols, rows) | c(width, height) mm | n_interior, tabsize |
| random | c(cols, rows) | c(width, height) mm | n_interior, tabsize |
| snic | c(cols, rows) | c(width, height) mm | n_interior, compactness, tabsize |
Got: User request mapped to valid generate_puzzle() args with correct type, grid dimensions, size in config.yml ranges.
If fail: Unsure of parameter format? See table. Rectangular + voronoi use c(cols, rows); hexagonal + concentric use c(rings).
Write script file (preferred over -e for complex commands):
library(jigsawR)
result <- generate_puzzle(
type = "rectangular",
seed = 42,
grid = c(3, 4),
size = c(400, 300),
offset = 0,
layout = "grid"
)
cat("Pieces:", length(result$pieces), "\n")
cat("SVG length:", nchar(result$svg_content), "\n")
cat("Files:", paste(result$files, collapse = ", "), "\n")
Save to temporary script file.
Got: R script file at temporary location, contains library(jigsawR), generate_puzzle() call with all parameters, diagnostic output lines.
If fail: Script syntax errors? Verify string args quoted + numeric vectors use c(). Skip complex shell escaping — always use script files.
R_EXE="/mnt/c/Program Files/R/R-4.5.0/bin/Rscript.exe"
"$R_EXE" /path/to/script.R
Got: Script done no errors. SVG file(s) written to output/.
If fail: Check renv restored (renv::restore()). Verify package loaded (devtools::load_all()). NO --vanilla flag (renv needs .Rprofile).
output/ directory<?xml or <svgGot: SVG file exists in output/, starts with <?xml or <svg, piece count matches grid (cols * rows rectangular, ring formula hex/concentric).
If fail: SVG file missing? Check output/ directory exists. Piece count wrong? Verify grid matches puzzle type formula. ggplot2 output → check plot renders by wrap in tryCatch().
Generated files saved to output/ default. result object contains:
$svg_content — raw SVG string$pieces — list of piece data$canvas_size — dimensions$files — paths to written filesGot: result object has $svg_content, $pieces, $canvas_size, $files fields. Files listed in $files exist on disk.
If fail: $files empty? Puzzle may have generated in-memory only. Save explicit with writeLines(result$svg_content, "output/puzzle.svg").
--vanilla flag: Breaks renv activation. Never use.-e commands: Use script files; shell escaping → Exit code 5.snic package installed.add-puzzle-type — scaffold new puzzle type end-to-endvalidate-piles-notation — validate fusion group strings before generate_puzzle()run-puzzle-tests — run test suite after generation changeswrite-testthat-tests — add tests for new generation scenarios