pp_cfg and as_pp_cfg creates piecepack configuration list R6 object. is_pp_cfg returns TRUE if object is a piecepack configuration list R6 object. as.list will convert it into a list.

pp_cfg(cfg = list())

is_pp_cfg(cfg)

as_pp_cfg(cfg = list())

Arguments

cfg

List of configuration options

Details

pp_cfg objects serve the following purposes:

  1. Customize the appearance of pieces drawn by grid.piece.

  2. Speed up the drawing of graphics through use of caching.

  3. Allow the setting and querying of information about the board game components that maybe of use to developers

    1. Number of suits

    2. Number of ranks

    3. Suit colors

    4. Which types of components are included and/or properly supported

    5. What would be a good color to use when adding annotations on top of these components.

    6. Title, Description, Copyright, and Credit metadata

pp_cfg R6 Class Method Arguments

piece_side

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

suit

Number of suit (starting from 1).

rank

Number of rank (starting from 1).

type

Which type of grob to return, either "normal", "picture", or "raster".

pp_cfg R6 Class Methods

get_grob

Returns a grid “grob” for drawing the piece.

get_piece_opt

Returns a list with info useful for drawing the piece.

get_suit_color

Returns the suit colors.

get_width, get_height, get_depth

Dimensions (of the bounding cube) of the piece in inches

See also

https://trevorldavis.com/piecepackr/configuration-lists.html for more details about piecepackr configuration lists. game_systems for functions that return configuration list objects for several game systems.

Examples

cfg <- pp_cfg(list(invert_colors=TRUE)) as.list(cfg)
#> $invert_colors #> [1] TRUE #>
is_pp_cfg(cfg)
#> [1] TRUE
as_pp_cfg(list(suit_color="darkred,black,darkgreen,darkblue,grey"))
#> $suit_color : darkred,black,darkgreen,darkblue,grey
cfg$get_suit_color(suit=3)
#> [1] "#009E73"
cfg$annotation_color
#> [1] "black"
cfg$has_matchsticks
#> [1] FALSE
cfg$has_matchsticks <- TRUE cfg$has_matchsticks
#> [1] TRUE
cfg$get_width("tile_back")
#> [1] 2
cfg$get_height("die_face")
#> [1] 0.5
cfg$get_depth("coin_face")
#> [1] 0.125
# \donttest{ cfg <- list() system.time(replicate(100, grid.piece("tile_face", 4, 4, cfg)))
#> user system elapsed #> 8.155 0.000 8.155
cfg <- pp_cfg(list()) system.time(replicate(100, grid.piece("tile_face", 4, 4, cfg)))
#> user system elapsed #> 0.398 0.000 0.399
# }