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.
Implementations§
Source§impl Deform
impl Deform
Sourcepub fn place(self, from: Rect, to: Rect, u: f64, v: f64) -> (f64, f64)
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.
Sourcepub fn segments(self) -> (u32, u32)
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.
Sourcepub fn is_at_rest(self) -> bool
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.
Sourcepub fn blend(
from: Option<Self>,
to: Option<Self>,
progress: f64,
) -> Option<Self>
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.
Sourcepub fn mix(self, other: Self, progress: f64) -> Self
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.
Sourcepub fn all() -> [(&'static str, Self); 1]
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.