Skip to contents

as_omsvg() converts a dee object to an omsvg "svg" class object using omsvg::SVG() and omsvg::svg_path().

Usage

as_omsvg(
  x,
  ...,
  height = getOption("dee.height"),
  width = getOption("dee.width"),
  background_color = getOption("dee.background_color", "none"),
  stroke = getOption("dee.stroke"),
  stroke_width = getOption("dee.stroke_width"),
  fill = getOption("dee.fill"),
  attrs = getOption("dee.attrs")
)

Arguments

x

An object of class "dee".

...

Passed to omsvg::svg_path().

height, width

svg width and height.

background_color

Background color.

stroke, stroke_width, fill, attrs

Passed to omsvg::svg_path().

Examples

s <- affiner::star_inner_radius(n = 5, d = 2)
d <- d_star(x = 50, y = 50, r = 30, s = s, n = 5, digits = 0)
if (requireNamespace("omsvg", quietly = TRUE)) {
  svg <- as_omsvg(d, height = 100, width = 100,
                fill = "fill", stroke = "none")
  paste(svg, collapse = "\n") |> cat("\n")
}
#> <svg width="100" height="100" viewBox="0 0 100 100">
#>   <path d="M 0,0 0,100 100,100 100,0 Z" stroke="none" fill="none"/>
#>   <path d="M 50,20 57,41 79,41 61,54 68,74 50,61 32,74 39,54 21,41 43,41 Z" stroke="none" fill="fill"/>
#> </svg>