Skip to main content

Deform

Enum Deform 

Source
pub enum Deform {
    Genie {
        progress: f32,
        spread: f32,
        axis: Axis,
    },
}
Expand description

A deformation a rectangle cannot express.

A small enum rather than a callback: a deform has to be blended between two frames, compared for equality, and named by a script, and a closure does none of those.

Variants§

§

Genie

Pulled from one rectangle into another like a sheet through a letterbox: the minimise, and the open that undoes it.

progress 0 draws the window where it is, 1 has all of it inside the far rectangle. The rows nearest that rectangle go first, and that lag is the whole effect: it bends the sheet instead of shrinking it. spread is how much of the window is in motion at once – 0 pulls it in rigidly, larger values draw the tail out behind it. axis is which edge leads.

Fields

§progress: f32
§spread: f32
§axis: Axis

Implementations§

Source§

impl Deform

Source

pub fn place(self, from: Rect, to: Rect, u: f64, v: f64) -> (f64, f64)

Where the point at (u, v) of a window’s unit square is drawn.

A morph between two rectangles, and both of them are arguments. from is where the window is being drawn and to is what it is being pulled into – a dock icon, a tab, another window. Neither is stored: the compositor resolves to from an identity once per frame, because a rectangle snapshotted when the script ran aims at where the dock icon was half a second ago.

Which of the two is the window is the caller’s choice, so there is no separate effect for the way back: swap them, or animate progress down instead of up, and the same function opens a window out of an icon that it minimised into one.

Source

pub fn segments(self) -> (u32, u32)

Columns and rows the mesh needs to look like a curve rather than a fan of flat pieces. Columns subdivide u, rows subdivide v.

The grid follows the axis, which is the whole reason the axis is a parameter and not two effects. Across the sweep the taper is linear, so a handful of cells only matters when a matrix is in play too; along it is where the bend lives and where every cell is one more step of phase.

Source

pub fn at_rest(self) -> Self

The same deform, doing nothing.

Source

pub fn is_at_rest(self) -> bool

Whether this deform draws the window exactly where it is: progress 0, or below it, which clamps to the same picture. tests::at_rest_a_deform_draws_the_window_exactly_where_it_is shows the picture; tests::a_genie_at_progress_zero_or_below_is_at_rest the rule.

Source

pub fn blend( from: Option<Self>, to: Option<Self>, progress: f64, ) -> Option<Self>

Blend two deforms, either of which may be absent.

Absent means “not deformed”, which for a genie is progress 0 – so a script animating into one does not have to name the starting state, and clearing one animates back out of it.

Source

pub fn mix(self, other: Self, progress: f64) -> Self

Blend towards another deform of the same kind.

Between different kinds there is no meaningful halfway, so the destination wins outright; a script wanting a hand-off animates one out and the next one in. The axis is the same: there is no rectangle half way between down and left, and a grid cannot be turned a quarter of the way round.

Source

pub fn all() -> [(&'static str, Self); 1]

Every effect, at its defaults, for tools that want to show them all.

This is the whole vocabulary Self::from_name knows, so it is also what a script may write – and what the shipped lua/*.lua is checked against by script::shipped. An effect added here is available to every script and to the preview the moment it compiles, with nothing to add in script.rs; that is the point of the crate.

Source

pub fn from_name(name: &str, params: &dyn Params) -> Option<Self>

Look an effect up by the name a script used, and read its parameters.

Mirrors Curve::from_name, including the part that matters: the names come from the engine rather than from a list kept in script.rs.

Source

pub fn name(self) -> &'static str

What to call this effect.

Source

pub(crate) fn with(self, params: &dyn Params) -> Self

This effect with whatever the caller named read into it. Anything it does not name keeps the default it already has.

Trait Implementations§

Source§

impl Clone for Deform

Source§

fn clone(&self) -> Deform

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 Deform

Source§

impl Debug for Deform

Source§

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

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

impl PartialEq for Deform

Source§

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

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.