bm_extend {bittermelon} | R Documentation |
Extend bitmaps on the sides with extra pixels
Description
bm_extend()
extends bm_bitmap()
objects with extra pixels.
The directions and the integer value of the extra pixels are settable
(defaulting to 0L
).
Usage
bm_extend(
x,
value,
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
## S3 method for class 'bm_bitmap'
bm_extend(
x,
value = 0L,
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
## S3 method for class 'bm_pixmap'
bm_extend(
x,
value = col2hex("transparent"),
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
## S3 method for class 'bm_list'
bm_extend(x, ...)
## S3 method for class ''magick-image''
bm_extend(
x,
value = "transparent",
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
## S3 method for class 'nativeRaster'
bm_extend(
x,
value = col2int("transparent"),
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
## S3 method for class 'raster'
bm_extend(
x,
value = "transparent",
sides = NULL,
top = NULL,
right = NULL,
bottom = NULL,
left = NULL,
width = NULL,
height = NULL,
hjust = "center-left",
vjust = "center-top"
)
Arguments
x |
Either a |
value |
Value for the new pixels. |
sides |
If not |
top |
How many pixels to pad the top. |
right |
How many pixels to pad the right. |
bottom |
How many pixels to pad the bottom. |
left |
How many pixels to pad the left. |
width |
How many pixels wide should the new bitmap be.
Use with the |
height |
How many pixels tall should the new bitmap be.
Use with the |
hjust |
One of "left", "center-left", "center-right", "right". "center-left" and "center-right" will attempt to place in "center" if possible but if not possible will bias it one pixel left or right respectively. "centre", "center", and "centre-left" are aliases for "center-left". "centre-right" is an alias for "center-right". |
vjust |
One of "bottom", "center-bottom", "center-top", "top". "center-bottom" and "center-top" will attempt to place in "center" if possible but if not possible will bias it one pixel down or up respectively. "centre", "center", and "centre-top" are aliases for "center-top". "centre-bottom" is an alias for "center-bottom". |
... |
Additional arguments to be passed to or from methods. |
Value
Depending on x
either a bm_bitmap()
, bm_font()
, bm_list()
, magick-image, "nativeRaster", bm_pixmap()
, or raster object.
See Also
bm_expand()
, bm_pad()
, bm_resize()
, and bm_trim()
.
Examples
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
# add a border to an "R"
capital_r <- font[[str2ucp("R")]]
capital_r <- bm_extend(capital_r, value = 2L, sides = 1L)
capital_r <- bm_extend(capital_r, value = 3L, sides = 1L)
print(capital_r)
crops <- farming_crops_16x16()
corn <- crops$corn$portrait
corn_framed <- bm_extend(corn, value = "brown", sides = 1L)
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
print(corn_framed, compress = "v")
}