Learn R Programming

bittermelon (version 2.2.1)

bm_rotate: Rotate bitmaps 0, 90, 180, or 270 degrees

Description

bm_rotate() losslessly rotates bitmaps by 0, 90, 180, or 270 degrees. If 90 or 270 degrees are indicated the width and height of the bitmap will be flipped.

Usage

bm_rotate(x, angle = 0L, clockwise = TRUE)

# S3 method for bm_matrix bm_rotate(x, angle = 0L, clockwise = TRUE)

# S3 method for nativeRaster bm_rotate(x, angle = 0L, clockwise = TRUE)

# S3 method for `magick-image` bm_rotate(x, angle = 0L, clockwise = TRUE)

# S3 method for raster bm_rotate(x, angle = 0L, clockwise = TRUE)

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

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.

angle

Angle to rotate bitmap by.

clockwise

If TRUE rotate bitmaps clockwise. Note Unicode's convention is to rotate glyphs clockwise i.e. the top of the "BLACK CHESS PAWN ROTATED NINETY DEGREES" glyph points right.

...

Additional arguments to be passed to or from methods.

See Also

bm_distort() can do other (distorted) rotations by careful use of its vp grid::viewport() argument. bm_flip() with direction "both" and in_place TRUE can rotate glyphs 180 degrees in place.

Examples

Run this code
# as_bm_list.character()
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
capital_r <- font[[str2ucp("R")]]
print(bm_rotate(capital_r, 90))
print(bm_rotate(capital_r, 180))
print(bm_rotate(capital_r, 270))
print(bm_rotate(capital_r, 90, clockwise = FALSE))

corn <- farming_crops_16x16()$corn$portrait
corn_180 <- bm_rotate(corn, 180)
if (cli::is_utf8_output() && cli::num_ansi_colors() >= 256L) {
  print(corn_180, compress = "v")
}

Run the code above in your browser using DataLab