Skip to contents

The canvas shows one embedded, downsampled image with the project's ROIs drawn in their label colours (hidden layers are left out; locked layers cannot be erased or moved on the canvas). It pans with a drag and zooms with the mouse wheel or a two-finger pinch. When no image can be shown, it says why instead of keeping a previous image.

Usage

at_canvas(
  img,
  project = NULL,
  tool = "pan",
  width = NULL,
  height = NULL,
  elementId = NULL,
  options = list(),
  view = NULL,
  call = rlang::caller_env()
)

Arguments

img

An annot_image to display.

project

Optional annot_project whose ROIs are shown initially.

tool

Initial tool: one of "pan", "rect", "polygon", "freehand", "circle", "point", "edit", "erase", "probe" (emit a pixel position for spectra) or "select" (emit the clicked ROI id).

width, height

Widget dimensions.

elementId

Optional element id.

options

A list of extra options passed to the widget: creationTarget (a list with layer, label and locked; drawing is refused on a locked target) and selection (ROI ids to highlight).

view

Optional band view passed to at_tile_source().

call

The calling environment, for error reporting.

Value

An htmlwidget object.

Shiny inputs

In Shiny, the canvas with output id id sends these inputs. Each value is a list entry_id, revision, payload: the identity rendered when the gesture began (the project's meta$entry_id and meta$annotation_revision, or the element id and 0 for a project without them) and the event data. A render or at_canvas_set_annotations() with a different identity cancels unfinished gestures, and stale events are never sent.

<id>_created

A drawn GeoJSON feature in level-0 pixels; target holds options$creationTarget (layer, label) as it was when the drawing began. A click with the rectangle or circle tool is not a shape.

<id>_edited

roi_id, layer, label and the moved geometry (sent only after an actual drag).

<id>_erased

The erased ROI id.

<id>_selected

The ids of the selected ROIs (possibly none).

<id>_probed

x, y: the probed level-0 pixel position.

<id>_viewport

zoom, center_x, center_y and bounds (xmin, ymin, xmax, ymax in level-0 pixels) after a pan or zoom.

<id>_ready

ready and error: whether the image is displayed.

A drawn or moved shape is shown dashed until new annotations arrive, and disappears after a few seconds if none do, so the canvas does not keep showing an ROI the app did not accept.

Examples

at_canvas(at_example_image("tissue"))