Skip to main content

NineSliceInsets

Struct NineSliceInsets 

Source
pub struct NineSliceInsets { /* private fields */ }
Expand description

The four per-edge border insets that carve an image into nine patches.

This is the pure geometry half of a nine-slice: it holds no image handle, so the split can be computed and tested without a DOM. Insets are clamped so left + right never exceeds the source width and top + bottom never exceeds the source height; a degenerate center patch collapses to zero size rather than inverting.

Implementations§

Source§

impl NineSliceInsets

Implements the nine-slice geometry math for NineSliceInsets.

All methods here are pure functions of the insets and the rectangle being split: no canvas context, no image handle, no DOM. That is what makes the split verifiable on the host, and it is the same math NineSlice::draw_into and NineSlice::record reuse.

Source

pub fn source_rects(&self, source: Rect) -> NineSliceRects

Splits a source rectangle into its nine sub-rectangles.

The insets are clamped against the source size so the nine results always tile the source exactly: the two horizontal insets share the available width and the two vertical insets share the available height, with the center taking whatever remains.

§Arguments
  • Rect - The full source rectangle to split.
§Returns
  • NineSliceRects - The nine source sub-rectangles in reading order.
Source

pub fn dest_rects(&self, dest: Rect) -> NineSliceRects

Splits a destination rectangle into its nine sub-rectangles.

Corners and edges keep their natural pixel size taken from the insets, and the center absorbs all remaining destination space, so the nine results tile the destination exactly. When the destination is smaller than the combined borders the center collapses to zero width and/or height instead of going negative.

§Arguments
  • Rect - The full destination rectangle to split.
§Returns
  • NineSliceRects - The nine destination sub-rectangles in reading order.
Source§

impl NineSliceInsets

Source

pub fn get_left(&self) -> f64

Source

pub fn get_mut_left(&mut self) -> &mut f64

Source

pub fn set_left(&mut self, val: f64) -> &mut Self

Source

pub fn get_right(&self) -> f64

Source

pub fn get_mut_right(&mut self) -> &mut f64

Source

pub fn set_right(&mut self, val: f64) -> &mut Self

Source

pub fn get_top(&self) -> f64

Source

pub fn get_mut_top(&mut self) -> &mut f64

Source

pub fn set_top(&mut self, val: f64) -> &mut Self

Source

pub fn get_bottom(&self) -> f64

Source

pub fn get_mut_bottom(&mut self) -> &mut f64

Source

pub fn set_bottom(&mut self, val: f64) -> &mut Self

Source§

impl NineSliceInsets

Source

pub fn new(left: f64, right: f64, top: f64, bottom: f64) -> Self

Trait Implementations§

Source§

impl Clone for NineSliceInsets

Source§

fn clone(&self) -> Self

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 NineSliceInsets

Source§

impl Debug for NineSliceInsets

Source§

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

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

impl Default for NineSliceInsets

Source§

fn default() -> Self

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

impl PartialEq for NineSliceInsets

Source§

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

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more