bm_clamp {bittermelon}R Documentation

Clamp bitmap integer values.

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

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

 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(".", "#", "@"))

[Package bittermelon version 1.1.1 Index]