Learn R Programming

bittermelon (version 2.2.1)

bm_flip: Flip (reflect) bitmaps

Description

bm_flip() flips (reflects) bitmaps horizontally, vertically, or both. It can flip the entire bitmap or just the glyph in place.

Usage

bm_flip(x, direction = "vertical", in_place = FALSE, value)

# S3 method for bm_bitmap bm_flip(x, direction = "vertical", in_place = FALSE, value = 0L)

# S3 method for bm_list bm_flip(x, ...)

# S3 method for bm_pixmap bm_flip( x, direction = "vertical", in_place = FALSE, value = col2hex("transparent") )

# S3 method for `magick-image` bm_flip(x, direction = "vertical", in_place = FALSE, value = "transparent")

# S3 method for nativeRaster bm_flip( x, direction = "vertical", in_place = FALSE, value = col2int("transparent") )

# S3 method for raster bm_flip(x, direction = "vertical", in_place = FALSE, value = "transparent")

Value

Depending on x either a bm_bitmap(), bm_font(), bm_list(), magick-image, "nativeRaster", bm_pixmap(), or raster object.

Arguments

x

Either a bm_bitmap(), bm_font(), bm_list(), "magick-image", "nativeRaster", bm_pixmap(), or "raster" object.

direction

Either "vertical" or "v", "horizontal" or "h", OR "both" or "b".

in_place

If TRUE flip the glyphs in place (without changing any background padding).

value

Background padding value (to use if in_place is TRUE)

...

Additional arguments to be passed to or from methods.

Examples

Run this code
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)

# Print upside down
bml <- as_bm_list("RSTATS", font = font)
bml <- bm_flip(bml, "both")
bm <- bm_call(bml, cbind, direction = "RTL")
print(bm)

# Can also modify glyphs "in place"
exclamation <- font[[str2ucp("!")]]
exclamation_flipped <- bm_flip(exclamation, in_place = TRUE)
print(exclamation_flipped)

crops <- farming_crops_16x16()
corn <- crops$corn$portrait
corn_fh <- bm_flip(corn, "h")
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
  print(corn_fh, compress = "v")
}

Run the code above in your browser using DataLab