as_bm_pixmap | R Documentation |
as_bm_pixmap()
casts an object to a [bm_pixmap()]
object.
as_bm_pixmap(x, ...)
## Default S3 method:
as_bm_pixmap(x, ...)
## S3 method for class 'array'
as_bm_pixmap(x, ...)
## S3 method for class 'bm_bitmap'
as_bm_pixmap(x, ..., col = getOption("bittermelon.col", col_bitmap))
## S3 method for class 'bm_pixmap'
as_bm_pixmap(x, ...)
## S3 method for class 'glyph_bitmap'
as_bm_pixmap(x, ..., col = getOption("bittermelon.col", col_bitmap))
## S3 method for class 'grob'
as_bm_pixmap(x, ..., width = 16L, height = 16L, png_device = NULL)
## S3 method for class ''lofi-matrix''
as_bm_pixmap(x, ..., col = getOption("bittermelon.col", col_bitmap))
## S3 method for class ''magick-image''
as_bm_pixmap(x, ...)
## S3 method for class 'matrix'
as_bm_pixmap(x, ...)
## S3 method for class 'maze'
as_bm_pixmap(
x,
...,
walls = FALSE,
start = NULL,
end = NULL,
solve = !is.null(start) && !is.null(end),
col = getOption("bittermelon.col", col_bitmap)
)
## S3 method for class 'pattern_square'
as_bm_pixmap(x, ..., col = getOption("bittermelon.col", col_bitmap))
## S3 method for class 'pattern_weave'
as_bm_pixmap(x, ..., col = getOption("bittermelon.col", col_bitmap))
## S3 method for class 'pixmapGrey'
as_bm_pixmap(x, ...)
## S3 method for class 'pixmapIndexed'
as_bm_pixmap(x, ...)
## S3 method for class 'pixmapRGB'
as_bm_pixmap(x, ...)
## S3 method for class 'nativeRaster'
as_bm_pixmap(x, ...)
## S3 method for class 'pixeltrix'
as_bm_pixmap(x, ...)
## S3 method for class 'raster'
as_bm_pixmap(x, ...)
x |
an Object |
... |
Potentially passed to other methods e.g. |
col |
Character vector of R color specifications. |
width |
Desired width of bitmap |
height |
Desired height of bitmap |
png_device |
A function taking arguments |
walls |
If |
start , end |
If not |
solve |
If |
A bm_pixmap()
object.
bm_pixmap()
, is_bm_pixmap()
crops <- farming_crops_16x16()
corn <- crops$corn$portrait
is_bm_pixmap(corn)
all.equal(corn, as_bm_pixmap(as.array(corn)))
all.equal(corn, as_bm_pixmap(as.raster(corn)))
if (requireNamespace("farver", quietly = TRUE)) {
all.equal(corn, as_bm_pixmap(as.raster(corn, native = TRUE)))
}
if (requireNamespace("magick", quietly = TRUE)) {
all.equal(corn, as_bm_pixmap(magick::image_read(corn)))
}
if (requireNamespace("mazing", quietly = TRUE) &&
cli::is_utf8_output() &&
cli::num_ansi_colors() >= 8L) {
pal <- grDevices::palette.colors()
pm <- as_bm_pixmap(mazing::maze(24L, 32L),
start = "top", end = "bottom",
col = c(pal[6], "white", pal[7], pal[5]))
pm <- bm_pad(pm, sides = 1L)
print(pm, compress = "v", bg = "white")
}
if (requireNamespace("gridpattern", quietly = TRUE) &&
cli::is_utf8_output() &&
cli::num_ansi_colors() >= 256L) {
s <- gridpattern::pattern_square(subtype = 8L, nrow = 8L, ncol = 50L)
pm <- as_bm_pixmap(s, col = grDevices::rainbow(8L))
print(pm, compress = "vertical")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.