The SVG()
function is the entry point for building an SVG from the ground
up. We can provide predefined height
and width
attributes that define
the canvas size for the SVG. From here, we would want to use functions that
add elements to the SVG object (e.g., svg_rect()
, svg_circle()
, etc.) and
thus progressively build the graphic.
SVG( width = NULL, height = NULL, viewbox = NULL, title = NULL, desc = NULL, incl_xmlns = FALSE, oneline = FALSE, anim_iterations = "infinite" )
width, height | The width and height attributes on the top-level |
---|---|
viewbox | An optional set of dimensions that defines the SVG |
title | The |
desc | The |
incl_xmlns | Should the |
oneline | An option to compress the resulting SVG tags such that they are reduced to one line. |
anim_iterations | How many should an SVG animation (if defined by use of
the |
# Create an SVG with nothing drawn # within it svg <- SVG(width = 200, height = 100) # Add a rectangle and then a circle svg <- svg %>% svg_rect(x = 20, y = 20, width = 40, height = 40) %>% svg_circle(x = 100, y = 40, diameter = 40)