cfg <- game_systems("sans", border = FALSE)$piecepack
rasterize_mesh <- function(mesh) {
opt <- options(cores = getOption("Ncpus"))
light <- rayvertex::directional_light(c(0, 0, 1))
lookat <- c(0, 0, 0)
rayvertex::rasterize_scene(mesh, light_info = light, lookat = lookat)
invisible(options(opt))
}
should_run_piece_mesh_example <- piecepackr:::donttest() &&
requireNamespace("rayvertex", quietly = TRUE) &&
all(capabilities(c("cairo", "png")))
if (should_run_piece_mesh_example) {
mesh <- piece_mesh("tile_face", suit = 3, rank = 3, cfg = cfg)
rasterize_mesh(mesh)
}
if (should_run_piece_mesh_example) {
mesh <- piece_mesh("coin_back", suit = 4, rank = 2, cfg = cfg)
rasterize_mesh(mesh)
}
if (should_run_piece_mesh_example) {
mesh <- piece_mesh("pawn_face", suit = 1, cfg = cfg)
rasterize_mesh(mesh)
}
Run the code above in your browser using DataLab