| pp_cfg | R Documentation |
pp_cfg() and as_pp_cfg() create piecepack configuration list R6 objects.
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())
cfg |
List of configuration options |
pp_cfg R6 class objects serve the following purposes:
Customize the appearance of pieces drawn by grid.piece().
Speed up the drawing of graphics through use of caching.
Allow the setting and querying of information about the board game components that maybe of use to developers:
Number of suits
Number of ranks
Suit colors
Which types of components are included and/or properly supported
What would be a good color to use when adding annotations on top of these components.
Title, Description, Copyright, License, and Credit metadata
pp_cfg R6 Class Method Argumentspiece_sideA string with piece and side separated by a underscore e.g. "coin_face".
suitNumber of suit (starting from 1).
rankNumber of rank (starting from 1).
typeWhich type of grob to return, either "normal", "picture", "raster", or "transformation".
scale"scale" factor
alpha"alpha" value
pp_cfg R6 Class Methodsget_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
pp_cfg R6 Class Fields and Active Bindingsannotation_colorSuggestion of a good color to annotate with
cacheCache object which stores intermediate graphical calculations.
Default is a memory-cache that does not prune.
This can be replaced by another cache that
implements the cache API used by the cachem package
cache_grobWhether we should cache (2D) grobs
cache_grob_with_bleed_fnWhether we should cache the grob with bleed functions
cache_piece_optWhether we should cache piece opt information
cache_op_fnWhether we should cache the oblique projection functions
cache_obj_fnWhether we should cache any 3D rendering functions
copyrightDesign copyright information
creditDesign credits
descriptionDesign description
fontfamilyMain font family
has_bitsWhether we should assume this supports "bit" pieces
has_boardsWhether we should assume this supports "board" pieces
has_cardsWhether we should assume this supports "card" pieces
has_coinsWhether we should assume this supports "coin" pieces
has_diceWhether we should assume this supports "die" pieces
has_matchsticksWhether we should assume this supports "matchstick" pieces
has_pawnsWhether we should assume this supports "pawn" pieces
has_piecepackBinding which simultaneously checks/sets
has_coins, has_tiles, has_pawns, has_dice
has_pyramidsWhether we should assume this supports "pyramid" pieces
has_saucersWhether we should assume this supports "saucer" pieces
has_tilesWhether we should assume this supports "tile" pieces
spdx_idSPDX Identifier for graphical design license. See https://spdx.org/licenses/ for full list.
titleDesign title
pp_cfg R6 Class attributes which have been removedcache_shadowUse cache_op_fn instead
i_unsuitInstead add 1L to n_suits
get_pictureGrob()Use get_grob(..., type = "picture") instead
get_shadow_fnget_op_grob() returns complete oblique projection grob
game_systems() for functions that return configuration list
objects for several game systems.
https://trevorldavis.com/piecepackr/configuration-lists.html for more details
about piecepackr configuration lists.
cfg <- pp_cfg(list(invert_colors=TRUE))
as.list(cfg)
is_pp_cfg(cfg)
as_pp_cfg(list(suit_color="darkred,black,darkgreen,darkblue,grey"))
cfg$get_suit_color(suit=3)
cfg$annotation_color
cfg$has_matchsticks
cfg$has_matchsticks <- TRUE
cfg$has_matchsticks
cfg$get_width("tile_back")
cfg$get_height("die_face")
cfg$get_depth("coin_face")
# May take more than 5 seconds on CRAN servers
# `pp_cfg()` objects use a cache to speed up repeated drawing
pdf(tempfile(fileext = ".pdf"))
cfg <- list()
system.time(replicate(100, grid.piece("tile_back", 4, 4, cfg)))
cfg <- pp_cfg(list())
system.time(replicate(100, grid.piece("tile_back", 4, 4, cfg)))
invisible(dev.off())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.