R/filter-turbulent-displacement.R
create_filter_turbulent_displacement.Rd
Use turblence to displace an element.
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 |
minisvg::SVGElement object representing a filter
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
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() }