Learn R Programming

bittermelon (version 2.2.1)

bm_replace: Replace a color in a bitmap with another color

Description

bm_replace() replaces a bitmap color with another color. In particular default arguments will try to replace the background color.

Usage

bm_replace(x, value, old)

# S3 method for bm_bitmap bm_replace(x, value = 0L, old = x[1L, 1L])

# S3 method for bm_list bm_replace(x, ...)

# S3 method for bm_pixmap bm_replace(x, value = col2hex("transparent"), old = x[1L, 1L])

# S3 method for `magick-image` bm_replace(x, value = "transparent", old = as.raster(x)[1L, 1L])

# S3 method for nativeRaster bm_replace(x, value = col2int("transparent"), old = x[1L, 1L])

# S3 method for raster bm_replace(x, value = "transparent", old = x[1L, 1L])

Value

Depending on x either a bm_bitmap(), bm_font(), bm_list(), magick-image, "nativeRaster", bm_pixmap(), or raster object.

Arguments

x

Either a bm_bitmap(), bm_font(), bm_list(), "magick-image", "nativeRaster", bm_pixmap(), or "raster" object.

value

New bitmap “color” value.

old

Old bitmap “color” value to replace.

...

Additional arguments to be passed to or from methods.

Examples

Run this code
corn <- farming_crops_16x16()$corn$portrait
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
  print(bm_replace(corn, "cyan"), compress = "v")
}
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
capital_r <- font[[str2ucp("R")]]
print(bm_replace(capital_r, 2L))

Run the code above in your browser using DataLab