create_filter_turbulent_displacement: Create an animated SVG turbulent displacement filter

Description Usage Arguments Details Value Examples

View source: R/filter-turbulent-displacement.R

Description

Use turblence to displace an element.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
create_filter_turbulent_displacement(
  id,
  scale = 50,
  octaves = 4,
  fps = 8,
  freqx = 0.05,
  freqy = freqx,
  frames = 20,
  ...
)

Arguments

id

id to use for filter.

scale

scale of the displacement

octaves

corresponds to feTurbulence - numOctaves parameter. default: 4

fps

frames per second. default: 8

freqx, freqy

base frequency in x and y directions. default: freqx = 0.05, freqy = freqx

frames

number of frames. default: 20

...

other arguments ignored

Details

The turbulent displacement effect is a combination of 2 primitive SVG filters:

  1. Create turbulence

  2. Use the turblence as a displacment map for the object

For more information see the MDN SVG docs for feTurbulence and feDisplacementMap

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
turb_filter <- create_filter_turbulent_displacement(id = 'turb')
doc$defs(turb_filter)

# Create a rectangle with the animation
rect  <- stag$rect(
  x      = "10%",
  y      = "10%",
  width  = "80%",
  height = "80%",
  fill   = "lightblue",
  stroke = 'black',
  filter = turb_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.