Skip to main content

Filter

Struct Filter 

Source
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

Source

pub fn empty() -> Self

Create a new empty filter graph.

Source

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.

Source

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.

Source

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.

Source

pub fn nodes(&self) -> &[FilterGraphNode]

The list of nodes in the graph

Source

pub fn output(&self) -> FilterId

The output filter for the graph.

Source

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
Source

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
Source

pub fn expansion_rect(&self) -> Rect

Trait Implementations§

Source§

impl Clone for Filter

Source§

fn clone(&self) -> Filter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Filter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Filter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Filter

Source§

fn eq(&self, other: &Filter) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Filter

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,