bm_clamp: Clamp bitmap integer values.

Description Usage Arguments Value Examples

View source: R/bm_clamp.R

Description

bm_clamp() “clamps” bitmap integers that lie outside an interval. The default coerces a multiple-integer-valued bitmap into a binary bitmap (as expected by most bitmap font formats).

Usage

1
bm_clamp(bm_object, lower = 0L, upper = 1L, value = upper)

Arguments

bm_object

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

lower

Integer value. Any value below lower will be clamped.

upper

Integer value. Any value above upper will be clamped.

value

Integer vector of length one or two of replacement value(s). If value is length one any values above upper are replaced by value while those below lower are replaced by lower. If value is length two any values above upper are replaced by value[2] and any values below lower are replaced by value[1].

Value

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

Examples

1
2
3
4
5
6
7
8
 plus_sign <- matrix(0L, nrow = 9L, ncol = 9L)
 plus_sign[5L, 3:7] <- 2L
 plus_sign[3:7, 5L] <- 2L
 plus_sign_glyph <- bm_bitmap(plus_sign)
 print(plus_sign_glyph, px = c(".", "#", "@"))

 plus_sign_clamped <- bm_clamp(plus_sign_glyph)
 print(plus_sign_clamped, px = c(".", "#", "@"))

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