fabric_shape_add {fabricerin}R Documentation

Add a shape object to a preexisting canvas element

Description

Add a shape object to a preexisting canvas element

Usage

fabric_shape_add(
  cid,
  shapeId,
  shape = "Rect",
  left = "100",
  top = "100",
  fill = "red",
  width = 200,
  height = 200,
  angle = 0,
  opacity = 1,
  strokecolor = "darkblue",
  strokewidth = 5,
  selectable = TRUE,
  radius = NULL,
  xPolygon = NULL,
  yPolygon = NULL
)

Arguments

cid

the id of the canvas element you want to add your shape to

shapeId

the id of the shape object

shape

the shape of the object. Choices include 'Circle', 'Triangle' and 'Rect'. Defaults to 'Rect'

left

the shape's position from the left relative to the canvas element. Defaults to 100

top

the shape's position from the top relative to the canvas element. Defaults to 100

fill

the color of the shape. Defaults to 'red'

width

the width of the shape. Defaults to 200

height

the height of the shape. Defaults to 200

angle

the angle of rotation of the shape. Defaults to 0 (no rotation)

opacity

the opacity of the shape. Defaults to 1

strokecolor

the stroke color of the shape. Defaults to 'darkblue'

strokewidth

the stroke width of the shape. Defaults to 5.

selectable

logical. If TRUE, the user can modify interactively the shape. Defaults to TRUE

radius

Mandatory if the chosen shape is a 'Circle'. Defaults to NULL

xPolygon

a vector of the coordinate points of the polygon, from the left.

yPolygon

a vector of the coordinate points of the polygon, from the top

Value

a shape object inside a preexisting canvas element

Examples


if (interactive()) {

ui <- fluidPage(


fabric_shape(cid = "canvas",
             shapeId = "shape1",
             shape = "Rect",
             left = 130,
             top = 200),

fabric_shape_add(cid = "canvas",
                 shapeId = "shapo",
                 shape = "Circle",
                 radius = 30,
                 left = 100,
                 top = 100),

fabric_shape_add(cid = "canvas",
                 shapeId = "shapa",
                 shape = "Circle",
                 radius = 30,
                 left = 200,
                 top = 100),

fabric_shape_add(cid = "canvas",
                 shapeId = "shapox",
                 shape = "Circle",
                 radius = 30,
                 left = 300,
                 top = 100),

fabric_shape_add(cid = "canvas",
                 shapeId = "shapor",
                 shape = "Circle",
                 radius = 30,
                 left = 300,
                 top = 100)

)


server <- function(input, output) {}

shinyApp(ui = ui, server = server)

}

[Package fabricerin version 0.1.2 Index]