as.data.frame.bm_bitmap {bittermelon} | R Documentation |
Convert to data frame with pixel (x,y) coordinates
Description
as.matrix.bm_matrix()
casts bm_bitmap()
objects to a (normal) integer matrix
and bm_pixmap()
objects to a (normal) character matrix (of color strings).
Usage
## S3 method for class 'bm_bitmap'
as.data.frame(x, ..., filtrate = FALSE)
## S3 method for class 'bm_pixmap'
as.data.frame(x, ..., filtrate = FALSE)
Arguments
x |
Either a |
... |
Currently ignored. |
filtrate |
If |
Value
A data frame with "x", "y", and "value" columns.
Examples
font_file <- system.file("fonts/fixed/4x6.yaff.gz", package = "bittermelon")
font <- read_yaff(font_file)
bm <- as_bm_bitmap("RSTATS", font = font)
df <- as.data.frame(bm, filtrate = 1L)
if (require("grid")) {
grid.newpage()
grid.rect(df$x * 0.6, df$y * 0.6, width = 0.5, height = 0.5,
gp = gpar(fill = 'black'), default.units = 'cm')
}
corn <- farming_crops_16x16()$corn$portrait
df <- as.data.frame(corn)
if (require("grid")) {
grid.newpage()
grid.circle(df$x * 0.6, df$y * 0.6, r = 0.25,
gp = gpar(fill = df$value), default.units = 'cm')
}
[Package bittermelon version 2.1.1 Index]