bm_pixmap: Bittermelon pixmap matrix object

View source: R/bm_pixmap.R

bm_pixmapR Documentation

Bittermelon pixmap matrix object

Description

bm_pixmap() creates an S3 matrix subclass representing a pixmap.

Usage

bm_pixmap(x)

Arguments

x

Object to be converted to bm_pixmap(). If not already a color string matrix it will be cast to one by as_bm_pixmap().

Details

  • Intended to represent raster graphic pixmaps especially (but not limited to) pixel art/sprites.

  • Pixmaps are represented as color string matrices with special class methods.

  • The bottom left pixel is represented by the first row and first column.

  • The bottom right pixel is represented by the first row and last column.

  • The top left pixel is represented by the last row and first column.

  • The top right pixel is represented by the last row and last column.

  • Colors are converted to the "#RRGGBBAA" color string format.

  • Fully transparent values like "transparent", NA, "#00000000" are all standardized to "#FFFFFF00".

  • See bm_bitmap() for an alternative S3 object backed by a integer matrix.

Value

A character matrix of color strings with a “bm_pixmap” subclass.

Supported S3 methods

  • [.bm_bitmap and [<-.bm_bitmap

  • as.matrix.bm_pixmap()

  • as.raster.bm_bitmap() and plot.bm_bitmap()

  • format.bm_pixmap() and print.bm_pixmap()

See Also

as_bm_pixmap(), is_bm_pixmap()

Examples

# Bottom left pixel is **first** row and first column
pm <- bm_pixmap(matrix(c("red", "blue", "green", "black"),
                nrow = 2L, byrow = TRUE))
plot(pm)

bittermelon documentation built on June 25, 2024, 5:09 p.m.