Skip to main content

Alignable

Trait Alignable 

Source
pub trait Alignable: Clone {
    // Required methods
    fn is_aligned(&self, other: &Self) -> bool;
    fn align_with(&mut self, other: &mut Self);
}
Expand description

A trait for aligning two items

Alignment is actually the meaning of preparation for interpolation.

For example, if we want to interpolate two VItems, we need to align all their inner components like ComponentVec<VPoint> to the same length.

Required Methods§

Source

fn is_aligned(&self, other: &Self) -> bool

Checking if two items are aligned

Source

fn align_with(&mut self, other: &mut Self)

Aligning two items

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Alignable for DVec3

Source§

fn align_with(&mut self, _other: &mut DVec3)

Source§

fn is_aligned(&self, _other: &DVec3) -> bool

Source§

impl Alignable for MeshItem

Source§

fn is_aligned(&self, other: &MeshItem) -> bool

Source§

fn align_with(&mut self, other: &mut MeshItem)

Source§

impl Alignable for Polygon

Source§

fn is_aligned(&self, other: &Polygon) -> bool

Source§

fn align_with(&mut self, other: &mut Polygon)

Source§

impl Alignable for Rectangle

Source§

fn align_with(&mut self, _other: &mut Rectangle)

Source§

fn is_aligned(&self, _other: &Rectangle) -> bool

Source§

impl Alignable for RegularPolygon

Source§

fn is_aligned(&self, _other: &RegularPolygon) -> bool

Source§

fn align_with(&mut self, _other: &mut RegularPolygon)

Source§

impl Alignable for Square

Source§

fn is_aligned(&self, _other: &Square) -> bool

Source§

fn align_with(&mut self, _other: &mut Square)

Source§

impl Alignable for TypstText

Source§

fn is_aligned(&self, other: &TypstText) -> bool

Source§

fn align_with(&mut self, other: &mut TypstText)

Source§

impl Alignable for VItem

Source§

fn is_aligned(&self, other: &VItem) -> bool

Source§

fn align_with(&mut self, other: &mut VItem)

Source§

impl<I, G> Alignable for Node<I, G>
where I: Alignable + Opacity, G: Clone,

Source§

fn is_aligned(&self, other: &Node<I, G>) -> bool

Whether both sides are already structurally compatible for direct interpolation: payload presence must match positionally, sibling counts must be equal, and every payload and child pair must satisfy Alignable::is_aligned. This mirrors the Vec<T> blanket’s pre-alignment contract; Alignable::align_with establishes this state from mismatched trees.

Source§

fn align_with(&mut self, other: &mut Node<I, G>)

Align two trees for interpolation under one uniform rule: absence is filled with a transparent clone of the present side.

  1. Payload presence: when only one side carries an item, the other side receives a transparent (set_opacity(0.0)) clone of it, so lerping fades the payload in or out smoothly instead of jumping.
  2. Payload pairs: when both sides carry items, they align with each other (vertex-level padding for point data).
  3. Children: unequal child counts are padded on both sides. A non-empty list grows by repeating its own entries (resize_preserving_order_with_repeated_indices, matching the Vec<T>: Alignable blanket); an empty list has nothing of its own to repeat, so it grows with transparent clones of the other side’s children — the same absence rule as payloads. Pairs recurse.
Source§

impl<T> Alignable for Vec<T>
where T: Opacity + Alignable + Clone,

Source§

fn is_aligned(&self, other: &Vec<T>) -> bool

Source§

fn align_with(&mut self, other: &mut Vec<T>)

Implementors§