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
impl Filter
sourcepub fn opacity<A: Into<Factor>>(self, alpha: A) -> Self
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.
sourcepub fn invert<A: Into<Factor>>(self, amount: A) -> Self
pub fn invert<A: Into<Factor>>(self, amount: A) -> Self
Add a color inversion filter, zero does not invert, one fully inverts.
sourcepub fn blur<R: Into<Length>>(self, radius: R) -> Self
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.
sourcepub fn sepia<A: Into<Factor>>(self, amount: A) -> Self
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.
sourcepub fn grayscale<A: Into<Factor>>(self, amount: A) -> Self
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.
sourcepub fn drop_shadow<O: Into<Point>, R: Into<Length>, C: Into<Rgba>>(
self,
offset: O,
blur_radius: R,
color: C
) -> Self
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.
sourcepub fn brightness<A: Into<Factor>>(self, amount: A) -> Self
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.
sourcepub fn contrast<A: Into<Factor>>(self, amount: A) -> Self
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.
sourcepub fn saturate<A: Into<Factor>>(self, amount: A) -> Self
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.
sourcepub fn hue_rotate<A: Into<AngleDegree>>(self, angle: A) -> Self
pub fn hue_rotate<A: Into<AngleDegree>>(self, angle: A) -> Self
Add a filter that adds the angle
to each color hue
value.
sourcepub fn flood<C: Into<Rgba>>(self, color: C) -> Self
pub fn flood<C: Into<Rgba>>(self, color: C) -> Self
Add a filter that fills the pixel space with color
.
sourcepub fn color_matrix<M: Into<ColorMatrix>>(self, matrix: M) -> Self
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
impl Filter
sourcepub fn new_opacity<A: Into<Factor>>(alpha: A) -> Filter
pub fn new_opacity<A: Into<Factor>>(alpha: A) -> Filter
New Filter::opacity
.
sourcepub fn new_invert<A: Into<Factor>>(amount: A) -> Filter
pub fn new_invert<A: Into<Factor>>(amount: A) -> Filter
New Filter::invert
.
sourcepub fn new_grayscale<A: Into<Factor>>(amount: A) -> Filter
pub fn new_grayscale<A: Into<Factor>>(amount: A) -> Filter
New Filter::grayscale
.
sourcepub fn new_drop_shadow<O: Into<Point>, R: Into<Length>, C: Into<Rgba>>(
offset: O,
blur_radius: R,
color: C
) -> Filter
pub fn new_drop_shadow<O: Into<Point>, R: Into<Length>, C: Into<Rgba>>( offset: O, blur_radius: R, color: C ) -> Filter
New Filter::drop_shadow
.
sourcepub fn new_brightness<A: Into<Factor>>(amount: A) -> Filter
pub fn new_brightness<A: Into<Factor>>(amount: A) -> Filter
New Filter::brightness
.
sourcepub fn new_contrast<A: Into<Factor>>(amount: A) -> Filter
pub fn new_contrast<A: Into<Factor>>(amount: A) -> Filter
New Filter::contrast
.
sourcepub fn new_saturate<A: Into<Factor>>(amount: A) -> Filter
pub fn new_saturate<A: Into<Factor>>(amount: A) -> Filter
New Filter::saturate
.
sourcepub fn new_hue_rotate<A: Into<AngleDegree>>(angle: A) -> Filter
pub fn new_hue_rotate<A: Into<AngleDegree>>(angle: A) -> Filter
New Filter::hue_rotate
.
sourcepub fn new_color_matrix<M: Into<ColorMatrix>>(matrix: M) -> Filter
pub fn new_color_matrix<M: Into<ColorMatrix>>(matrix: M) -> Filter
New Filter::color_matrix
.
source§impl Filter
impl Filter
sourcepub fn layout(&self) -> RenderFilter
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.
sourcepub fn try_render(&self) -> Option<RenderFilter>
pub fn try_render(&self) -> Option<RenderFilter>
Compute a RenderFilter
if the filter is not affected by layout.
sourcepub fn needs_layout(&self) -> bool
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 Layout2d for Filter
impl Layout2d for Filter
source§fn layout_dft(&self, _: Self::Px) -> Self::Px
fn layout_dft(&self, _: Self::Px) -> Self::Px
LAYOUT
context with default
.source§fn affect_mask(&self) -> LayoutMask
fn affect_mask(&self) -> LayoutMask
LayoutMask
that flags all contextual values that affect the result of layout
.source§impl PartialEq for Filter
impl PartialEq for Filter
source§impl Transitionable for Filter
impl Transitionable for Filter
source§fn lerp(self, to: &Self, step: EasingStep) -> Self
fn lerp(self, to: &Self, step: EasingStep) -> Self
self
-> to
by step
. 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> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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