pub struct Filter {
pub graph: Arc<FilterGraph>,
}Expand description
The main filter system.
A filter combines a graph of filter primitives with optional spatial bounds. If bounds are specified, the filter only applies within that region.
Fields§
§graph: Arc<FilterGraph>Filter graph defining the effect pipeline.
Implementations§
Source§impl Filter
impl Filter
Sourcepub fn from_function(function: FilterFunction) -> Self
pub fn from_function(function: FilterFunction) -> Self
Create a simple filter system from a filter function.
Converts a high-level CSS-style filter function into a filter graph. Use this for simple effects like blur, brightness, etc.
Sourcepub fn from_primitive(primitive: FilterPrimitive) -> Self
pub fn from_primitive(primitive: FilterPrimitive) -> Self
Create a filter system from a filter primitive.
Creates a simple filter graph with a single primitive. Use this for direct access to low-level SVG filter operations.
Sourcepub fn bounds_expansion(&self, transform: &Affine) -> Rect
pub fn 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