bm_split_layout() extracts print-and-play components from a layout.
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.- bleed
Include the bleed (if available).
Value
A bittermelon::bm_list() of bittermelon::bm_pixmap() objects.
See also
bm_crop_layout() to just crop a single component
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)
cards <- bm_split_layout(page, layout = layout)
grid::grid.raster(cards[[1L]])
unlink(input)
}