pub enum FilterEffect {
Show 16 variants
Flood(AlphaColor<Srgb>),
GaussianBlur(GaussianBlurFilter),
DropShadow(DropShadow),
ColorMatrix(ColorMatrix),
Offset(Vec2),
Composite(CompositeOperator),
Blend(BlendMode),
Morphology(MorphologyFilter),
ConvolveMatrix(ConvolutionKernel),
Turbulence(TurbulenceFilter),
DisplacementMap(DisplacementMapFilter),
ComponentTransfer(ComponentTransferFilter),
Image(ExternalImageSource),
Tile,
DiffuseLighting(DiffuseLightingFilter),
SpecularLighting(SpecularLightingFilter),
}Expand description
Low-level filter primitives for granular control (SVG filter primitives).
These are the building blocks for complex filter effects, corresponding to SVG
filter primitives. They can be combined in a FilterGraph to create sophisticated
visual effects.
See: https://drafts.fxtf.org/filter-effects/#FilterPrimitivesOverview
Variants§
Flood(AlphaColor<Srgb>)
Generate a solid color fill.
Creates a rectangle filled with the specified color, typically used as input to other filter operations (e.g., for colored shadows).
GaussianBlur(GaussianBlurFilter)
Gaussian blur filter.
Applies a Gaussian blur using the specified standard deviation (σ).
The effective blur range (distance over which pixels are sampled) is
approximately 3 × std_deviation, as this captures ~99.7% of the
Gaussian distribution.
DropShadow(DropShadow)
Drop shadow effect (compound primitive).
Creates a drop shadow by blurring the input’s alpha channel, offsetting it, and compositing it with the original. This is a compound operation that combines multiple primitive operations into one.
See: https://drafts.fxtf.org/filter-effects-2/#feDropShadowElement
ColorMatrix(ColorMatrix)
Matrix-based color transformation.
Applies a 4x5 matrix transformation to colors, allowing arbitrary color space transformations, hue shifts, and color adjustments.
4x5 color transformation matrix: 4 rows (R,G,B,A) × 5 columns (R,G,B,A,offset). Each output channel is computed as a linear combination of input channels plus offset.
Offset(Vec2)
Geometric offset/translation.
Shifts the input image by the specified offset. Useful for creating shadow effects or positioning elements in a filter graph.
Positive values shift right or down.
Composite(CompositeOperator)
Composite two inputs using Porter-Duff compositing operations.
Combines two input images using standard compositing operators (over, in, out, atop, xor) or custom arithmetic combination.
Blend(BlendMode)
Blend two inputs using blend modes.
Combines two input images using Photoshop-style blend modes (multiply, screen, overlay, etc.).
Morphology(MorphologyFilter)
Morphological operations (dilate/erode).
Expands (dilate) or contracts (erode) the shapes in the input image. Useful for creating outline effects or cleaning up edges.
ConvolveMatrix(ConvolutionKernel)
Custom convolution kernel for image processing.
Applies a custom convolution matrix to the input image, enabling effects like sharpening, edge detection, embossing, and custom filters.
Turbulence(TurbulenceFilter)
Generate Perlin noise/turbulence patterns.
Creates procedural noise patterns useful for textures, clouds, marble effects, and other organic-looking randomness.
DisplacementMap(DisplacementMapFilter)
Displace pixels using a displacement map.
Uses the color values from a second input to spatially displace pixels in the primary input, creating warping and distortion effects.
ComponentTransfer(ComponentTransferFilter)
Per-channel component transfer using lookup tables or functions.
Applies independent transfer functions to each color channel, enabling color corrections, gamma adjustments, and custom mappings.
Image(ExternalImageSource)
Tile
Tile the input to fill the filter region.
Repeats the input image to fill the entire filter primitive subregion, creating a tiling/repeating pattern.
DiffuseLighting(DiffuseLightingFilter)
Diffuse lighting simulation.
Creates a lighting effect by treating the input’s alpha channel as a height map and calculating diffuse (matte) reflection from a light source.
SpecularLighting(SpecularLightingFilter)
Specular lighting simulation.
Creates a lighting effect by treating the input’s alpha channel as a height map and calculating specular (shiny) reflection highlights from a light source.
Implementations§
Source§impl FilterEffect
impl FilterEffect
Sourcepub fn blur(radius: f32) -> Self
pub fn blur(radius: f32) -> Self
Gaussian blur effect.
Applies a Gaussian blur to the input image. Larger radius values produce more blur. The blur is applied equally in all directions.
Sourcepub fn drop_shadow(
dx: f32,
dy: f32,
std_deviation: f32,
color: AlphaColor<Srgb>,
) -> Self
pub fn drop_shadow( dx: f32, dy: f32, std_deviation: f32, color: AlphaColor<Srgb>, ) -> Self
Drop shadow effect (compound primitive).
Creates a drop shadow by blurring the input’s alpha channel, offsetting it, and compositing it with the original. This is a compound operation that combines multiple primitive operations into one.
See: https://drafts.fxtf.org/filter-effects-2/#feDropShadowElement
Sourcepub fn brightness(amount: f32) -> Self
pub fn brightness(amount: f32) -> Self
Construct a CSS brightness() filter effect
Sourcepub fn hue_rotate(angle_radians: f32) -> Self
pub fn hue_rotate(angle_radians: f32) -> Self
Construct a CSS hue-rotate() filter effect
Sourcepub fn expansion_rect(&self) -> Rect
pub fn expansion_rect(&self) -> Rect
Calculate the bounds expansion as a Rect in user space.
Returns a rectangle centered at the origin representing how much the filter expands the processing region in each direction. The rect coordinates are:
- x0: negative left expansion
- y0: negative top expansion
- x1: positive right expansion
- y1: positive bottom expansion
A Rect::ZERO means no expansion. This representation allows the expansion
to be correctly transformed (including rotation) using standard rect transforms.
For example, a blur filter needs additional pixels around the edges (3*sigma).
Most filters that don’t sample neighboring pixels return Rect::ZERO.
Trait Implementations§
Source§impl Clone for FilterEffect
impl Clone for FilterEffect
Source§fn clone(&self) -> FilterEffect
fn clone(&self) -> FilterEffect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more