Skip to contents

The canvas uses local array pixel coordinates (top-left origin, x right, y down). Drawing emits Shiny inputs suffixed _created, _edited, and _erased. Use sg_canvas_correct() to stage changes to a mask.

Usage

sg_canvas(
  image,
  mask = NULL,
  channel = 1L,
  tool = "pan",
  width = NULL,
  height = 600,
  elementId = NULL
)

Arguments

image

An sg_image.

mask

Optional sg_mask bound to the same image.

channel

One-based display channel.

tool

Drawing tool.

width, height

Widget dimensions.

elementId

Optional widget id.

Value

An HTML widget.

Examples

img <- new_sg_image(matrix(seq_len(72), 8, 9), id = "slide")
msk <- new_sg_mask(matrix(0L, 8, 9), image_id = "slide")
widget <- sg_canvas(img, msk, tool = "polygon")
class(widget)
#> [1] "sgcanvas"   "htmlwidget"
if (interactive()) widget