bm_crop_layout() crops out a print-and-play component from a layout.
Usage
bm_crop_layout(
page,
...,
layout = "button_shy_cards",
row = 1L,
col = 1L,
bleed = FALSE,
name = NULL
)Arguments
- page
A
bittermelon::bm_pixmap()object representing a print-and-play layout page. Often the output frompdf_render_bm_pixmap().- ...
Ignored for now.
- layout
Either a layout preset name in
layout_names()or a data frame with layout data (as returned bylayout_grid()). A preset name is centered on the paper size inferred from the aspect ratio of the bitmap bybm_paper(); it is an error if no supported paper size can be inferred.- row, col
The
rowandcolof the component in the layout (integers).- bleed
Include the bleed (if available).
- name
Instead of
rowandcolcan instead use the name of the component in the layout (string).
Value
A bittermelon::bm_pixmap() object.
See also
bm_split_layout() to extract all components from the layout
Examples
# Create a mock print-and-play layout page of playing cards
if (requireNamespace("bittermelon", quietly = TRUE) &&
requireNamespace("piecepackr", quietly = TRUE) &&
utils::packageVersion("piecepackr") >= "1.17.1" &&
capabilities("cairo")) {
layout <- layout_preset("poker_3x3", paper = "letter")
df <- transform(layout, piece_side = "card_face", suit = 1L, rank = 1:9)
cfg <- piecepackr::game_systems(border = FALSE, systems = "playing_cards")$playing_cards
input <- tempfile(fileext = ".pdf")
grDevices::cairo_pdf(input, width = 8.5, height = 11)
piecepackr::pmap_piece(df, cfg = cfg, default.units = "in")
invisible(grDevices::dev.off())
page <- pdf_render_bm_pixmap(input, page = 1L, dpi = 75)
card <- bm_crop_layout(page, layout = layout, row = 1L, col = 1L)
grid::grid.raster(card)
unlink(input)
}