bm_resize: Resize bitmaps by trimming and/or extending

Description Usage Arguments Details Value See Also Examples

View source: R/bm_resize.R

Description

Trim and/or extend bitmaps to a desired height and/or width.

Usage

1
2
3
4
5
6
7
8
bm_resize(
  bm_object,
  value = 0L,
  width = NULL,
  height = NULL,
  hjust = "center-left",
  vjust = "center-top"
)

Arguments

bm_object

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

value

Integer value for the new pixels.

width

How many pixels wide should the new bitmap be. Use with the hjust argument or just one of either the left or right arguments.

height

How many pixels tall should the new bitmap be. Use with the vjust argument or just one of either the top or bottom arguments.

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

This function is a convenience wrapper around bm_trim() and bm_extend().

Value

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

See Also

bm_extend(), bm_pad(), and bm_trim().

Examples

1
2
3
4
5
6
7
 font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
 font <- read_hex(font_file)
 # add a border to an "R"
 capital_r <- font[[str2ucp("R")]]
 print(capital_r, px = c("-", "#"))
 capital_r <- bm_resize(capital_r, width = 12L, height = 12L, vjust = "top")
 print(capital_r, px = c("-", "#"))

bittermelon documentation built on Nov. 2, 2021, 1:06 a.m.