bm_pixel_picker: Bitmap pixel picker

View source: R/bm_pixel_picker.R

bm_pixel_pickerR Documentation

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 class 'bm_bitmap'
bm_pixel_picker(
  x,
  ...,
  col = getOption("bittermelon.col", col_bitmap),
  silent = FALSE
)

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

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

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.

Value

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

See Also

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

Examples

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

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