pub struct Filter { /* private fields */ }Expand description
A directed acyclic graph (DAG) of filter operations.
The graph represents a pipeline of filter primitives where outputs of some
primitives can be used as inputs to others. Each primitive has a unique FilterId.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn single(primitive: FilterEffect) -> Self
pub fn single(primitive: FilterEffect) -> Self
Create a filter from a single filter effect.
Creates a simple filter graph with a single primitive. Use this for direct access to low-level SVG filter operations.
Sourcepub fn linear_list(primitives: impl Iterator<Item = FilterEffect>) -> Self
pub fn linear_list(primitives: impl Iterator<Item = FilterEffect>) -> Self
Create a filter from an iterator of filter effects.
Creates a filter graph where the effects are applied in order.
Sourcepub fn add(&mut self, effect: FilterEffect, inputs: FilterInputs) -> FilterId
pub fn add(&mut self, effect: FilterEffect, inputs: FilterInputs) -> FilterId
Add a filter primitive with optional inputs.
Returns a FilterId that can be referenced by other primitives.
Automatically updates the accumulated bounds expansion based on the primitive’s requirements.
Sourcepub fn nodes(&self) -> &[FilterGraphNode]
pub fn nodes(&self) -> &[FilterGraphNode]
The list of nodes in the graph
Sourcepub fn linear_bounds_expansion(&self, transform: &Affine) -> Rect
pub fn linear_bounds_expansion(&self, transform: &Affine) -> Rect
Calculate the bounds expansion for this filter in pixel/device space.
Returns a Rect representing how many extra pixels are needed around the
filtered region to correctly compute the filter effect. For example, a blur
filter needs to sample beyond the original bounds to avoid edge artifacts.
The expansion accounts for the transform (rotation, scale, and shear) to compute the correct axis-aligned bounding box expansion in device space.
The returned rect is centered at origin:
- x0: negative left expansion (in pixels)
- y0: negative top expansion (in pixels)
- x1: positive right expansion (in pixels)
- y1: positive bottom expansion (in pixels)
§Arguments
transform- The transform applied to this filter layer
Sourcepub fn bounds_expansion(&self, transform: &Affine) -> Rect
pub fn bounds_expansion(&self, transform: &Affine) -> Rect
Get the accumulated bounds expansion for all primitives in this graph.
This returns the expansion required by all primitives in the graph, representing the padding needed to render all filter effects correctly.
The expansion accounts for the transform (rotation, scale, and shear) to compute the correct axis-aligned bounding box expansion in device space.
§Arguments
transform- The transform applied to this filter layer