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_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"
, "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_color
Suggestion of a good color to annotate with
cache
Cache 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_grob
Whether we should cache (2D) grobs
cache_grob_with_bleed_fn
Whether we should cache the grob with bleed functions
cache_piece_opt
Whether we should cache piece opt information
cache_op_fn
Whether we should cache the oblique projection functions
cache_obj_fn
Whether we should cache any 3D rendering functions
copyright
Design copyright information
credit
Design credits
description
Design description
fontfamily
Main font family
has_bits
Whether we should assume this supports "bit" pieces
has_boards
Whether we should assume this supports "board" pieces
has_cards
Whether we should assume this supports "card" pieces
has_coins
Whether we should assume this supports "coin" pieces
has_dice
Whether we should assume this supports "die" pieces
has_matchsticks
Whether we should assume this supports "matchstick" pieces
has_pawns
Whether we should assume this supports "pawn" pieces
has_piecepack
Binding which simultaneously checks/sets
has_coins
, has_tiles
, has_pawns
, has_dice
has_pyramids
Whether we should assume this supports "pyramid" pieces
has_saucers
Whether we should assume this supports "saucer" pieces
has_tiles
Whether we should assume this supports "tile" pieces
spdx_id
SPDX Identifier for graphical design license. See https://spdx.org/licenses/ for full list.
title
Design title
pp_cfg
R6 Class attributes which have been removedcache_shadow
Use cache_op_fn
instead
i_unsuit
Instead add 1L
to n_suits
get_pictureGrob()
Use get_grob(..., type = "picture")
instead
get_shadow_fn
get_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.