Description Usage Arguments Details Value Examples
View source: R/filter-turbulent-displacement.R
Use turblence to displace an element.
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,
  ...
)
 | 
id | 
 id to use for filter.  | 
scale | 
 scale of the displacement  | 
octaves | 
 corresponds to   | 
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  | 
The turbulent displacement effect is a combination of 2 primitive SVG filters:
Create turbulence
Use the turblence as a displacment map for the object
For more information see the MDN SVG docs for feTurbulence and feDisplacementMap
minisvg::SVGElement object representing a filter
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)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.