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

View source: R/bm_rotate.R

bm_rotateR Documentation

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 class 'bm_matrix'
bm_rotate(x, angle = 0L, clockwise = TRUE)

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

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

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

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

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.

Value

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

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

# 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")
}

trevorld/bittermelon documentation built on Dec. 24, 2024, 10:33 p.m.