Skip to main content

FilterFunction

Enum FilterFunction 

Source
pub enum FilterFunction {
    Blur {
        radius: f32,
    },
    Brightness {
        amount: f32,
    },
    Contrast {
        amount: f32,
    },
    Grayscale {
        amount: f32,
    },
    HueRotate {
        angle: f32,
    },
    Invert {
        amount: f32,
    },
    Opacity {
        amount: f32,
    },
    Saturate {
        amount: f32,
    },
    Sepia {
        amount: f32,
    },
}
Expand description

High-level filter functions for common effects (CSS filter functions).

These match the CSS Filter Effects specification and provide simple, commonly-used visual effects without needing to construct a filter graph.

See: https://drafts.fxtf.org/filter-effects/#filter-functions

Variants§

§

Blur

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.

Note: Per the W3C Filter Effects specification, this radius parameter represents the standard deviation (σ) of the Gaussian function, not the effective blur range. The effective blur range is approximately 3× this value.

Fields

§radius: f32

Standard deviation of the Gaussian blur in pixels. Must be non-negative. A value of 0 means no blur.

Despite being called “radius” (to match CSS filter syntax), this is actually the standard deviation. The visible blur effect extends approximately 3 times this value in each direction.

§

Brightness

Brightness adjustment.

Adjusts the brightness of the input image using a linear multiplier.

Fields

§amount: f32

Brightness amount: 0.0 = completely black, 1.0 = no change, >1.0 = brighter. Must be non-negative.

§

Contrast

Contrast adjustment.

Adjusts the contrast of the input image.

Fields

§amount: f32

Contrast amount: 0.0 = uniform gray, 1.0 = no change, >1.0 = higher contrast. Must be non-negative.

§

Grayscale

Grayscale conversion.

Converts the input to grayscale. Amount controls the strength of the conversion.

Fields

§amount: f32

Grayscale amount: 0.0 = original colors, 1.0 = full grayscale. Values should be in range [0.0, 1.0].

§

HueRotate

Hue rotation.

Rotates the hue of all colors in the input image by the specified angle.

Fields

§angle: f32

Rotation angle in degrees. Can be negative. 0° = no change, 180° = opposite hue, 360° = back to original.

§

Invert

Color inversion.

Inverts the colors of the input image.

Fields

§amount: f32

Inversion amount: 0.0 = original colors, 1.0 = fully inverted. Values should be in range [0.0, 1.0].

§

Opacity

Opacity adjustment.

Multiplies the alpha channel by the specified amount.

Fields

§amount: f32

Opacity amount: 0.0 = fully transparent, 1.0 = no change. Values should be in range [0.0, 1.0].

§

Saturate

Saturation adjustment.

Adjusts the color saturation of the input image.

Fields

§amount: f32

Saturation amount: 0.0 = completely desaturated (grayscale), 1.0 = no change, >1.0 = oversaturated. Must be non-negative.

§

Sepia

Sepia tone effect.

Applies a sepia tone effect (vintage/old photo appearance).

Fields

§amount: f32

Sepia amount: 0.0 = original colors, 1.0 = full sepia tone. Values should be in range [0.0, 1.0].

Trait Implementations§

Source§

impl Clone for FilterFunction

Source§

fn clone(&self) -> FilterFunction

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 FilterFunction

Source§

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

Formats the value using the given formatter. Read more

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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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.