bm_overlay {bittermelon}R Documentation

Merge bitmaps by overlaying one over another

Description

bm_overlay() merges bitmaps by overlaying a bitmap over another.

Usage

bm_overlay(
  bm_object,
  over = NULL,
  under = NULL,
  hjust = "center-left",
  vjust = "center-top"
)

Arguments

bm_object

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

over

A 'bm_bitmap()' object to overlay over the bm_object bitmap(s). Only one of over or under may be set.

under

A 'bm_bitmap()' object which will be overlaid by the bm_object bitmap(s). Only one of over or under may be set.

hjust

One of "left", "center-left", "center-right", "right". "center-left" and "center-right" will attempt to place in "center" if possible but if not possible will bias it one pixel left or right respectively. "centre", "center", and "centre-left" are aliases for "center-left". "centre-right" is an alias for "center-right".

vjust

One of "bottom", "center-bottom", "center-top", "top". "center-bottom" and "center-top" will attempt to place in "center" if possible but if not possible will bias it one pixel down or up respectively. "centre", "center", and "centre-top" are aliases for "center-top". "centre-bottom" is an alias for "center-bottom".

Details

If necessary bitmaps will be extended by bm_extend() such that they are the same size. Then the non-zero pixels of the “over” bitmap will be inserted into the “under” bitmap.

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)
  grave <- font[[str2ucp("`")]]
  a <- font[[str2ucp("a")]]
  a_grave <- bm_overlay(a, over = grave)
  print(a_grave, px = px_ascii)

  # Can also instead specify the under glyph as a named argument
  a_grave2 <- bm_overlay(grave, under = a)
  print(a_grave2, px = px_ascii)

[Package bittermelon version 1.1.2 Index]