bm_pad() adjusts bitmap padding lengths.

bm_pad(
  bm_object,
  value = 0L,
  type = c("exact", "extend", "trim"),
  sides = NULL,
  top = NULL,
  right = NULL,
  bottom = NULL,
  left = NULL
)

Arguments

bm_object

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

value

Integer value for the new pixels.

type

Either "exact", `"extend", or "trim". "exact" makes sure the padding is exactly the indicated amount, "extend" does not trim any padding if existing padding is more than the indicated amount, and "trim" does not extend any padding if existing padding is less than the indicated amount.

sides

If not NULL then an integer vector indicating the desired number of pixels of padding on all four sides. If the integer vector is of length one it indicates the number of pixels for all four sides. If of length two gives first the number for the vertical sides and then the horizontal sides. If of length three gives the number of pixels for top, the horizontal sides, and then bottom sides. If of length four gives the number of pixels for top, right, bottom, and then left sides. This is the same scheme as used by the CSS padding and margin properties.

top

Desired number of pixels of padding on the top.

right

Desired number of pixels of padding on the right.

bottom

Desired number of pixels of padding on the bottom.

left

Desired number of pixels of padding on the left.

Value

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

See also

Examples

font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon") font <- read_hex(font_file) capital_r <- font[[str2ucp("R")]] print(capital_r, px = c(".", "#"))
#> ........ #> ........ #> ######.. #> ##...##. #> ##...##. #> ##...##. #> ######.. #> ##...##. #> ##...##. #> ##...##. #> ##...##. #> ##...##. #> ........ #> ........ #> ........ #> ........
capital_r_padded <- bm_pad(capital_r, sides = 2L) print(capital_r_padded, px = c(".", "#"))
#> ........... #> ........... #> ..######... #> ..##...##.. #> ..##...##.. #> ..##...##.. #> ..######... #> ..##...##.. #> ..##...##.. #> ..##...##.. #> ..##...##.. #> ..##...##.. #> ........... #> ...........