SVG_t {omsvg}R Documentation

Create a text-height svg object

Description

The SVG_t() function is a variation on SVG() (the entry point for building an SVG) in that the output tags will be both as compact as possible (fewer linebreaks, less space characters) and the height is relative to line height of text (at "0.75em"). This is a good option if the eventual use for the generated SVG is to be integrated with text in HTML ⁠<p>⁠ elements. For scaling to function properly, the provision of the viewbox is required here.

Usage

SVG_t(height = "0.75em", viewbox)

Arguments

height

The height attribute on the top-level ⁠<svg>⁠ element. The default of "0.75em" is recommended here so that SVGs are scaled nicely to any adjacent text.

viewbox

An optional set of dimensions that defines the SVG viewBox attribute. The viewBox for an SVG element is the position and dimension, in user space, of an SVG viewport. If supplied, this could either be in the form of a four-element, numeric vector corresponding to the "min-x", "min-y", "width", and "height" of the rectangle, or, as TRUE which uses the vector c(0, 0, width, height). Using NULL, the default, excludes this attribute.

Value

An svg object.

Examples

if (interactive()) {

# Create a simple SVG with a rectangle and a circle
svg <-
  SVG_t(viewbox = c(0, 0, 60, 20)) %>%
  svg_rect(x = 0, y = 0, width = 30, height = 20) %>%
  svg_circle(x = 50, y = 10, diameter = 20)
}


[Package omsvg version 0.1.0 Index]