basicPieceGrob, pyramidTopGrob, and previewLayoutGrob are the default “grob” functions that grid.piece uses to create grid graphical grob objects. picturePieceGrobFn is a function that returns a “grob” function that imports graphics from files found in its directory argument.

basicPieceGrob(piece_side, suit, rank, cfg = pp_cfg())

picturePieceGrobFn(directory, filename_fn = find_pp_file)

pyramidTopGrob(piece_side, suit, rank, cfg = pp_cfg())

previewLayoutGrob(piece_side, suit, rank, cfg = pp_cfg())



A string with piece and side separated by a underscore e.g. "coin_face"


Number of suit (starting from 1).


Number of rank (starting from 1)


Piecepack configuration list or pp_cfg object.


Directory that picturePieceGrobFn will look in for piece graphics.


Function that takes arguments directory, piece_side, suit, and rank and returns the (full path) filename of the image that the function returned by picturePieceGrobFn should import.


if (require("grid")) { cfg <- pp_cfg(list(invert_colors=TRUE)) pushViewport(viewport(width=unit(2, "in"), height=unit(2, "in"))) grid.draw(basicPieceGrob("tile_face", suit=1, rank=3)) popViewport() grid.newpage() pushViewport(viewport(width=unit(0.75, "in"), height=unit(0.75, "in"))) grid.draw(basicPieceGrob("coin_back", suit=2, rank=0, cfg=cfg)) popViewport() grid.newpage() pushViewport(viewport(width=unit(6, "in"), height=unit(6, "in"))) grid.draw(previewLayoutGrob("preview_layout", suit=5, rank=0, cfg=cfg)) popViewport() grid.newpage() pushViewport(viewport(width=unit(0.75, "in"), height=unit(0.75, "in"))) grid.draw(pyramidTopGrob("pyramid_top", suit=3, rank=5)) popViewport() # \donttest{ directory <- tempdir() save_piece_images(cfg, directory=directory, format="svg", angle=0) cfg2 <- pp_cfg(list(grob_fn=picturePieceGrobFn(directory))) grid.newpage() pushViewport(viewport(width=unit(0.75, "in"), height=unit(0.75, "in"))) grid.draw(pyramidTopGrob("pyramid_top", suit=3, rank=5, cfg=cfg2)) popViewport() # } }
#> Loading required package: grid