[][src]Struct nines::Layout

pub struct Layout<Dst, Src> {
    pub dst: Dst,
    pub src: Src,
    pub style: Style,
}

Describe a layout to render with. You'll probably start with a:

use nines::*;
 
let layout = Layout {
    src: Dimensions {
        outer: Rect::xywh(0, 0, 3, 3),
        inner: Rect::xywh(1, 1, 1, 1),
    },
    dst: Dimensions {
        outer: Rect::xywh(0, 0, 5, 4),
        inner: Rect::xywh(1, 1, 3, 2),
    },
    style: Style::default(), // stretch
};
 
let mut rects = Vec::new();
layout.validate().unwrap().each_dst_src(|dst, src|{
    rects.push((*dst, *src));
});
 
assert_eq!(rects[0].0, Rect::xywh(0, 0, 1, 1));
assert_eq!(rects[1].0, Rect::xywh(1, 0, 3, 1));
// ...
 
assert_eq!(rects[0].1, Rect::xywh(0, 0, 1, 1));
assert_eq!(rects[1].1, Rect::xywh(1, 0, 1, 1));
// ...

Fields

dst: Dstsrc: Srcstyle: Style

Methods

impl<S: Scalar> Layout<Dimensions<S>, Dimensions<S>>[src]

pub fn validate(
    &self
) -> Result<Layout<ValidDimensions<S>, ValidDimensions<S>>, Error>
[src]

Validate that dst and src contain valid (non-negative sized, non-NAN) dimensions.

impl<S: Scalar> Layout<ValidDimensions<S>, ValidDimensions<S>>[src]

pub fn each_dst_src(
    &self,
    each_dst_src: impl FnMut(&ValidRect<S>, &ValidRect<S>)
)
[src]

Enumerate the destination and source rectangles for a layout.

Trait Implementations

impl<S: Scalar> TryFrom<Layout<Dimensions<S>, Dimensions<S>>> for Layout<ValidDimensions<S>, ValidDimensions<S>>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<Dst, Src> Send for Layout<Dst, Src> where
    Dst: Send,
    Src: Send

impl<Dst, Src> Sync for Layout<Dst, Src> where
    Dst: Sync,
    Src: Sync

impl<Dst, Src> Unpin for Layout<Dst, Src> where
    Dst: Unpin,
    Src: Unpin

impl<Dst, Src> UnwindSafe for Layout<Dst, Src> where
    Dst: UnwindSafe,
    Src: UnwindSafe

impl<Dst, Src> RefUnwindSafe for Layout<Dst, Src> where
    Dst: RefUnwindSafe,
    Src: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]