bm_extract() can be used to extract part of a bitmap.
For bm_bitmap() and bm_pixmap() objects it is a wrapper around [[()] with drop = FALSE for convenience in pipes.
Usage
bm_extract(x, ...)
# S3 method for class 'bm_matrix'
bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)
# S3 method for class 'bm_list'
bm_extract(x, ...)
# S3 method for class '`magick-image`'
bm_extract(x, rows = seq_len(bm_heights(x)), cols = seq_len(bm_widths(x)), ...)
# S3 method for class 'nativeRaster'
bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)
# S3 method for class 'raster'
bm_extract(x, rows = seq_len(nrow(x)), cols = seq_len(ncol(x)), ...)Arguments
- x
Either a
bm_bitmap(),bm_font(),bm_list(), "magick-image", "nativeRaster",bm_pixmap(), or "raster" object.- ...
Additional arguments to be passed to or from methods.
- rows, cols
Integer vectors of rows and columns to extract. Rows are indexed from the bottom of the image.
See also
[[.bm_matrix()], bm_trim()
Examples
corn <- farming_crops_16x16()$corn$portrait
corn_top <- bm_extract(corn, rows = 9:16)
all.equal(corn_top, corn[9:16, ])
#> [1] TRUE
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
print(corn_top, bg = "cyan", compress = "v")
}
#>
#> ▄▀▀▄▄▀█
#> █▀▀▀▀█▀▀▄
#> ▄▀▀▀█▀█▀▀▀▄