Skip to main content

Effect

Struct Effect 

Source
pub struct Effect {
    pub opacity: f32,
    pub offset: Point,
    pub scale: f32,
}
Expand description

A visual change applied to painted content without touching layout: what a compositor would do to a layer, here done to the display list.

Fields§

§opacity: f32

Multiplies alpha, 0.0 to 1.0. Each primitive fades on its own, so shapes that overlap show through each other while partly faded.

§offset: Point

Movement in logical pixels.

§scale: f32

Size multiplier around the pivot.

Implementations§

Source§

impl Effect

Source

pub const IDENTITY: Effect

No change.

Source

pub const fn hidden() -> Effect

Fully transparent.

Source

pub const fn moved(x: f32, y: f32) -> Effect

Moved by (x, y) logical pixels.

Source

pub const fn scaled(scale: f32) -> Effect

Scaled around the pivot.

Source

pub const fn with_opacity(self, opacity: f32) -> Effect

The same effect with this opacity.

Source

pub const fn with_scale(self, scale: f32) -> Effect

The same effect with this scale.

Source

pub fn lerp(self, to: Effect, t: f32) -> Effect

The effect t of the way from self to to: 0.0 is self, 1.0 is to. t is not clamped, so springs and overshooting curves carry through.

Source

pub fn then(self, next: Effect) -> Effect

self followed by next, as one effect: opacities and scales multiply and offsets add, the way two nested elements with these effects would look.

Source

pub fn is_identity(&self) -> bool

True when applying the effect would change nothing.

Trait Implementations§

Source§

impl Animatable for Effect

Source§

const REST: f32 = 0.002

Below this distance from the target, the animation counts as finished.
Source§

fn to_components(self) -> [f32; 4]

The value as numbers to interpolate.
Source§

fn from_components(c: [f32; 4]) -> Effect

The value back from interpolated numbers, which may overshoot.
Source§

impl Clone for Effect

Source§

fn clone(&self) -> Effect

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 Copy for Effect

Source§

impl Debug for Effect

Source§

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

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

impl Default for Effect

Source§

fn default() -> Effect

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

impl PartialEq for Effect

Source§

fn eq(&self, other: &Effect) -> 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 Effect

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> AutoreleaseSafe for T
where T: ?Sized,

Source§

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

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
§

impl<T> Brush for T
where T: Clone + PartialEq + Default + Debug,

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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

§

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