bm_distort {bittermelon} | R Documentation |
bm_distort()
resize images to arbitrary width and height value via distortion.
bm_distort(
bm_object,
width = NULL,
height = NULL,
interpolate = FALSE,
vp = NULL,
png_device = NULL,
threshold = 0.25
)
bm_object |
Either a |
width |
Desired width of bitmap |
height |
Desired height of bitmap |
interpolate |
Passed to |
vp |
A |
png_device |
A function taking arguments |
threshold |
If any png channel weakly exceeds this threshold (on an interval from zero to one) then the pixel is determined to be “black”. |
bm_distort()
generates a distorted grid::rasterGrob()
with the help of
as.raster.bm_bitmap()
which is then converted back to a
bm_bitmap()
via as_bm_bitmap.grob()
.
Either a bm_bitmap()
, bm_list()
, or bm_font()
object.
bm_expand()
for expanding width/height by integer multiples.
bm_resize()
for resizing an image via trimming/extending an image.
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
capital_r <- font[[str2ucp("R")]]
dim(capital_r) # 8 x 16
if (require("grid") && capabilities("png")) {
print(bm_distort(capital_r, width = 9L, height = 21L), px = px_ascii)
}