filter_drop_shadow: Filter: add a drop shadow to an element

Description Usage Arguments Value Examples

View source: R/filters.R

Description

With the filter_drop_shadow() drop shadow appears beneath the input image or shape and its offset is controlled by dx and dy. The blurring of the drop shadow is set by the stdev value.

Usage

1
filter_drop_shadow(dx = 0.2, dy = 0.2, stdev = 1, color = "black", opacity = 1)

Arguments

dx, dy

The offset of the drop shadow compared to the position of the input image or shape.

stdev

The number of standard deviations for the blur effect.

color

The color of the drop shadow.

opacity

The opacity of the drop shadow. We can use a real number from 0 to 1 or a value in percentage units.

Value

An svg object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
if (interactive()) {

# Apply a drop shadow filter on a
# text element (orange in color,
# and semi-opaque)
SVG(width = 250, height = 100) %>%
  svg_filter(
    id = "shadow",
    filters = list(
      filter_drop_shadow(
        dx = 1, dy = 2,
        color = "orange",
        opacity = 0.5
      )
    )
  ) %>%
  svg_text(
    x = 10, y = 40,
    text = "Shadowed",
    attrs = svg_attrs_pres(
      font_size = "2em",
      fill = "#555555",
      font_weight = "bolder",
      filter = "shadow"
    )
  )
}

omsvg documentation built on Feb. 10, 2021, 5:10 p.m.