Learn R Programming

bittermelon (version 2.2.1)

bm_pixel_picker: Bitmap pixel picker

Description

bm_pixel_picker() lets you use an interactive graphics device to click on a bitmap's pixels and learn the column/row coordinates for the clicked pixel and its integer/color value. To end the program click a non-left mouse button within the graphics device.

Usage

bm_pixel_picker(x, ...)

# S3 method for bm_bitmap bm_pixel_picker( x, ..., col = getOption("bittermelon.col", col_bitmap), silent = FALSE )

# S3 method for bm_pixmap bm_pixel_picker(x, ..., silent = FALSE)

# S3 method for raster bm_pixel_picker(x, ..., silent = FALSE)

Value

A list with named components "row", "col", and "value" for the last clicked pixel returned invisibly.

Arguments

x

Either a bm_bitmap(), bm_pixmap(), or raster object

...

Currently ignored.

col

Character vector of R color specifications. First color is used for values equal to 0, second color for values equal to 1, etc.

silent

Don't generate messages about clicked pixels.

See Also

This function wraps grid::grid.locator().

Examples

Run this code
if (interactive() && dev.interactive(orNone = TRUE)) {
  corn <- farming_crops_16x16()$corn$portrait
  bm_pixel_picker(corn)
}

Run the code above in your browser using DataLab