pp_cfg: Configuration list R6 object

Description Usage Arguments Details pp_cfg R6 Class Method Arguments pp_cfg R6 Class Methods pp_cfg R6 Class Fields and Active Bindings Deprecated pp_cfg R6 Class attributes See Also Examples

View source: R/pp_cfg.R

Description

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.

Usage

1
2
3
4
5
pp_cfg(cfg = list())

is_pp_cfg(cfg)

as_pp_cfg(cfg = list())

Arguments

cfg

List of configuration options

Details

pp_cfg R6 class objects serve the following purposes:

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

pp_cfg R6 Class Fields and Active Bindings

annotation_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_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

title

Design title

Deprecated pp_cfg R6 Class attributes

cache_shadow

Use cache_op_fn instead

get_pictureGrob()

Use get_grob(..., type = "picture") instead

i_unsuit

Instead add 1L to n_suits

See Also

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 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")
 
   cfg <- list()
   system.time(replicate(100, grid.piece("tile_face", 4, 4, cfg)))
   cfg <- pp_cfg(list())
   system.time(replicate(100, grid.piece("tile_face", 4, 4, cfg)))
 

trevorld/piecepack documentation built on July 22, 2021, 3:26 a.m.