bm_flip: Flip (reflect) bitmaps

View source: R/bm_flip.R

bm_flipR Documentation

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(bm_object, direction = "vertical", in_place = FALSE)

Arguments

bm_object

Either a bm_bitmap(), bm_list(), or bm_font() 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 white space padding).

Value

Either a bm_bitmap(), bm_list(), or bm_font() object.

Examples

  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, px = px_ascii)

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

bittermelon documentation built on Feb. 16, 2023, 8:08 p.m.