Use turblence to displace an element.

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

Value

minisvg::SVGElement object representing a filter

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

Examples

if (FALSE) { # 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() }