Skip to contents

[.bm_matrix() is defined so that it returns a bm_bitmap() or bm_pixmap() object (if the value is a matrix). [<-.bm_bitmap() casts any replacement values as integers while [<-.bm_pixmap() casts any replacement values as standardized color strings.

Usage

# S3 method for class 'bm_matrix'
x[i, j, ..., drop = TRUE]

# S3 method for class 'bm_bitmap'
x[i, j, ...] <- value

# S3 method for class 'bm_pixmap'
x[i, j, ...] <- value

Arguments

x

bm_bitmap() object

i, j

indices specifying elements to extract or replace. See [base::[()] for more information.

...

Passed to [base::[()].

drop

If TRUE the result is coerced to a integer vector.

value

Replacement value

Value

[.bm_matrix() returns a bm_bitmap() or bm_pixmap() object if the value is a matrix and/or drop is FALSE otherwise it returns a vector of integers or color strings.

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[4:14,2:8])
#> █████░░
#> █░░░██░
#> █░░░██░
#> █░░░██░
#> █████░░
#> █░░░██░
#> █░░░██░
#> █░░░██░
#> █░░░██░
#> █░░░██░
#> ░░░░░░░
 capital_r[11:13,3:5] <- 2L
 print(capital_r)
#> ░░░░░░░░
#> ░░░░░░░░
#> ██████░░
#> ██▒▒▒██░
#> ██▒▒▒██░
#> ██▒▒▒██░
#> ██████░░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ░░░░░░░░
#> ░░░░░░░░
#> ░░░░░░░░
#> ░░░░░░░░