Struct zng_color::filter::Filter

source ·
pub struct Filter { /* private fields */ }
Expand description

A color filter or combination of filters.

§Examples

use zng_color::filter::Filter;
use zng_layout::unit::*;

let filter = Filter::new_opacity(50.pct()).blur(3);

The example above creates a filter that lowers the opacity to 50% and blurs by 3px.

Implementations§

source§

impl Filter

source

pub fn opacity<A: Into<Factor>>(self, alpha: A) -> Self

Add an opacity adjustment to the filter, zero is fully transparent, one is the input transparency.

source

pub fn invert<A: Into<Factor>>(self, amount: A) -> Self

Add a color inversion filter, zero does not invert, one fully inverts.

source

pub fn blur<R: Into<Length>>(self, radius: R) -> Self

Add a blue effect to the filter, the blue radius is defined by a Length.

Relative lengths are calculated by the width of the available space.

source

pub fn sepia<A: Into<Factor>>(self, amount: A) -> Self

Add a sepia color effect to the filter, zero is the input color, one is the full desaturated brown look.

source

pub fn grayscale<A: Into<Factor>>(self, amount: A) -> Self

Add a grayscale color effect to the filter, zero is the input color, one if the full grayscale.

source

pub fn drop_shadow<O: Into<Point>, R: Into<Length>, C: Into<Rgba>>( self, offset: O, blur_radius: R, color: C ) -> Self

Add a drop-shadow to the effect.

source

pub fn brightness<A: Into<Factor>>(self, amount: A) -> Self

Add a brightness adjustment to the filter, zero removes all brightness, one is the input brightness.

source

pub fn contrast<A: Into<Factor>>(self, amount: A) -> Self

Add a contrast adjustment to the filter, zero removes all contrast, one is the input contrast.

source

pub fn saturate<A: Into<Factor>>(self, amount: A) -> Self

Add a saturation adjustment to the filter, zero fully desaturates, one is the input saturation.

source

pub fn hue_rotate<A: Into<AngleDegree>>(self, angle: A) -> Self

Add a filter that adds the angle to each color hue value.

source

pub fn flood<C: Into<Rgba>>(self, color: C) -> Self

Add a filter that fills the pixel space with color.

source

pub fn color_matrix<M: Into<ColorMatrix>>(self, matrix: M) -> Self

Custom filter.

The color matrix is in the format of SVG color matrix, [0..5] is the first matrix row.

source§

impl Filter

source

pub const fn new() -> Filter

New default empty.

source

pub fn new_opacity<A: Into<Factor>>(alpha: A) -> Filter

source

pub fn new_invert<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_blur<R: Into<Length>>(radius: R) -> Filter

source

pub fn new_sepia<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_grayscale<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_drop_shadow<O: Into<Point>, R: Into<Length>, C: Into<Rgba>>( offset: O, blur_radius: R, color: C ) -> Filter

source

pub fn new_brightness<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_contrast<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_saturate<A: Into<Factor>>(amount: A) -> Filter

source

pub fn new_hue_rotate<A: Into<AngleDegree>>(angle: A) -> Filter

source

pub fn new_flood<C: Into<Rgba>>(color: C) -> Filter

source

pub fn new_color_matrix<M: Into<ColorMatrix>>(matrix: M) -> Filter

source§

impl Filter

source

pub fn layout(&self) -> RenderFilter

Compute a RenderFilter in the current LAYOUT context.

Most filters convert one-to-one, effects that have a Length value use the layout context to calculate relative values.

Relative blur radius lengths are calculated using the constraints().fill_size().width value.

source

pub fn try_render(&self) -> Option<RenderFilter>

Compute a RenderFilter if the filter is not affected by layout.

source

pub fn needs_layout(&self) -> bool

Returns true if this filter is affected by the layout context where it is evaluated.

Trait Implementations§

source§

impl Clone for Filter

source§

fn clone(&self) -> Filter

Returns a copy of the value. Read more
1.0.0 · 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() -> Filter

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

impl Layout2d for Filter

§

type Px = Vec<FilterOp>

Pixel type.
source§

fn layout_dft(&self, _: Self::Px) -> Self::Px

Compute the pixel value in the current LAYOUT context with default.
source§

fn affect_mask(&self) -> LayoutMask

Compute a LayoutMask that flags all contextual values that affect the result of layout.
source§

fn layout(&self) -> Self::Px

Compute the pixel value in the current LAYOUT context.
source§

impl PartialEq for Filter

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Transitionable for Filter

source§

fn lerp(self, to: &Self, step: EasingStep) -> Self

Sample the linear interpolation from self -> to by step.
source§

impl StructuralPartialEq for Filter

Auto Trait Implementations§

§

impl Freeze for Filter

§

impl RefUnwindSafe for Filter

§

impl Send for Filter

§

impl Sync for Filter

§

impl Unpin for Filter

§

impl UnwindSafe for Filter

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> AnyVarValue for T
where T: VarValue,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Access to dyn Any methods.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Access to mut dyn Any methods.
source§

fn clone_boxed(&self) -> Box<dyn AnyVarValue>

Clone the value.
source§

fn clone_boxed_var(&self) -> Box<dyn AnyVar>

Clone the value into a new boxed LocalVar<Self>.
source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Access to Box<dyn Any> methods.
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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> IntoVar<T> for T
where T: VarValue,

§

type Var = LocalVar<T>

Variable type that will wrap the T value. Read more
source§

fn into_var(self) -> <T as IntoVar<T>>::Var

Converts the source value into a var.
source§

fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>
where Self: Sized,

Converts into BoxedVar<T>. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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>,

§

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> IntoValue<T> for T
where T: VarValue,

source§

impl<T> VarValue for T
where T: Debug + Clone + PartialEq + Any + Send + Sync,