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 withlayer,labelandlocked; drawing is refused on a locked target) andselection(ROI ids to highlight).- view
Optional band view passed to
at_tile_source().- call
The calling environment, for error reporting.
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>_createdA drawn GeoJSON feature in level-0 pixels;
targetholdsoptions$creationTarget(layer,label) as it was when the drawing began. A click with the rectangle or circle tool is not a shape.<id>_editedroi_id,layer,labeland the movedgeometry(sent only after an actual drag).<id>_erasedThe erased ROI id.
<id>_selectedThe ids of the selected ROIs (possibly none).
<id>_probedx,y: the probed level-0 pixel position.<id>_viewportzoom,center_x,center_yandbounds(xmin,ymin,xmax,ymaxin level-0 pixels) after a pan or zoom.<id>_readyreadyanderror: 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"))