piece() creates 3d board game piece objects for use with the rayrender package.
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)
- cfg
Piecepack configuration list or
pp_cfgobject, a list ofpp_cfgobjects, or a character vector referring to names inenviror a character vector referring to object names that can be retrieved bybase::dynGet().- x
Where to place piece on x axis of viewport
- y
Where to place piece on y axis of viewport
- z
z-coordinate of the piece. Has no effect if
op_scaleis0.- angle
Angle (on xy plane) to draw piece at
- axis_x
First coordinate of the axis unit vector.
- axis_y
Second coordinate of the axis unit vector.
- width
Width of piece
- height
Height of piece
- depth
Depth (thickness) of piece. Has no effect if
op_scaleis0.- envir
Environment (or named list) containing configuration list(s).
- ...
Ignored.
- scale
Multiplicative scaling factor to apply to width, height, and depth.
- res
Resolution of the faces.
See also
See https://www.rayrender.net for more information about the rayrender package.
See geometry_utils for a discussion of the 3D rotation parameterization.
Examples
opt <- options(cores = getOption("Ncpus"))
cfg <- game_systems("sans", border = FALSE)$piecepack
should_run_piece_example <- piecepackr:::donttest() &&
requireNamespace("rayrender", quietly = TRUE) &&
all(capabilities(c("cairo", "png")))
if (should_run_piece_example) {
scene <- piece("tile_face", suit = 3, rank = 3, cfg = cfg)
rayrender::render_scene(scene)
}
if (should_run_piece_example) {
scene <- piece("coin_back", suit = 4, rank = 2, cfg = cfg)
rayrender::render_scene(scene)
}
if (should_run_piece_example) {
scene <- piece("pawn_face", suit = 2, cfg = cfg)
rayrender::render_scene(scene)
}
options(opt)