create_filter_drop_shadow: Create an SVG drop shadow filter

Description Usage Arguments Details Value Examples

View source: R/filter-drop-shadow.R

Description

This filter adds a drop shadow to the element it is applied to.

Usage

1
2
3
4
5
6
7
8
create_filter_drop_shadow(
  id,
  dx = 10,
  dy = dx,
  std_dev = 3,
  colour = "#bbb",
  ...
)

Arguments

id

id to use for filter.

dx, dy

offset of shadow in x and y directions. default: 10

std_dev

standard deviation of the gaussian for the blur. default: 3

colour

default: #bbb

...

other arguments ignored

Details

The drop shadow effect is a combination of 4 primitive SVG filters:

  1. Blur the element

  2. Offset this blurred image

  3. Fill the blurred image with the given colour using a flood and a composite

  4. Layer the drop shadow behind the original image

For more information see the MDN SVG docs for feGaussianBlur

Value

minisvg::SVGElement object representing a filter

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
## Not run: 
# Create an SVG document
library(minisvg)
doc   <- minisvg::svg_doc()

# Create the filter and add to the SVG definitions
drop_shadow_filter <- create_filter_drop_shadow(id = 'dshadow')
doc$defs(drop_shadow_filter)

# Create a rectangle with the animation
rect  <- stag$rect(
  x      = "10%",
  y      = "10%",
  width  = "80%",
  height = "80%",
  fill   = "lightblue",
  stroke = 'black',
  filter = drop_shadow_filter
)

# Add this rectangle to the document, show the SVG text, then render it
doc$append(rect)
doc
doc$show()

## End(Not run)

coolbutuseless/svgfilter documentation built on Feb. 9, 2020, 12:20 a.m.