svg_filter {omsvg}R Documentation

Build an SVG ⁠<filter>⁠

Description

The svg_filter() let's us create a named ⁠<filter>⁠ element that we can apply to any SVG elements (such as shapes). We can bundle one or more filter elements by supplying a list of ⁠filter_*()⁠ calls to the filters argument.

Usage

svg_filter(svg, id, width = NULL, height = NULL, filters = list())

Arguments

svg

The svg object that is created using the SVG() function.

id

The ID value to assign to the filter. This must be provided and it should be unique among all ⁠<filter>⁠ elements.

width, height

The lengths of width and height define the extent of the filter.

filters

A list of ⁠filter_*()⁠ function calls. Examples include filter_image() and filter_gaussian_blur().

Value

An svg object.

Examples

if (interactive()) {

# Set up an `svg_filter()` (called
# `"blur"`) that has the blur effect
# (using the `filter_gaussian_blur()`
# function); have the ellipse element
# use the filter by referencing it
# by name via the `"filter"` attribute
SVG(width = 200, height = 100) %>%
  svg_filter(
    id = "blur",
    filters = list(
      filter_gaussian_blur(stdev = 2)
    )
  ) %>%
  svg_ellipse(
    x = 40, y = 40,
    width = 50, height = 30,
    attrs = svg_attrs_pres(
      fill = "green",
      filter = "blur"
    )
  )
}


[Package omsvg version 0.1.0 Index]