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 filter_expansion(&self, transform: &Affine) -> Rect
pub fn filter_expansion(&self, transform: &Affine) -> Rect
Calculate how far the filtered output can extend beyond the source content.
The returned Rect is an expansion around the source content bounds, expressed
in device space after applying the linear part of transform. Negative x0/y0
values expand to the left/top; positive x1/y1 values expand to the right/bottom.
§Arguments
transform- The transform applied to this filter layer
Sourcepub fn source_expansion(&self, transform: &Affine) -> Rect
pub fn source_expansion(&self, transform: &Affine) -> Rect
Calculate how far the source input must extend outside the visible source bounds to render the filter correctly.
In most cases (for example for Gaussian blurs), this is the same as
Filter::filter_expansion. However, it isn’t the same for drop shadows.
Let’s say we have a drop shadow of dx = 20 and dy = 20. In this case,
the filter expansion rect will be [0, 0, 20, 20], meaning we need to extend
our pixmap 20 pixels to the right/bottom to fully render the filter effect.
Filter::source_expansion will instead return [-20, -20, 0, 0]. For example,
let’s say the rect is placed in such a way that the drop shadow starts at (0, 0).
In this case, we need to expand the source area by twenty pixels to the top/left
to ensure that the drop shadow is not cut off.