Skip to main content

NineSliceRects

Struct NineSliceRects 

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

The nine source or destination sub-rectangles produced by a nine-slice split.

Stored as a three-by-three grid in reading order — row 0 is the top (TOP_LEFT, TOP, TOP_RIGHT), row 1 the middle (LEFT, CENTER, RIGHT), row 2 the bottom (BOTTOM_LEFT, BOTTOM, BOTTOM_RIGHT). The named accessors read through those indices, so callers get self-documenting access while the storage stays a single array that can be iterated directly when emitting the nine drawImage calls.

Implementations§

Source§

impl NineSliceRects

Implements named access over the three-by-three nine-slice grid.

The index constants live in this module’s const.rs; each accessor maps a grid position to a self-documenting name so call sites and assert messages read as geometry rather than as (row, column) pairs.

Source

pub fn get_top_left(&self) -> Rect

Returns the top-left corner sub-rectangle.

§Returns
  • Rect - The top-left corner patch.
Source

pub fn get_top(&self) -> Rect

Returns the top edge sub-rectangle.

§Returns
  • Rect - The top edge patch.
Source

pub fn get_top_right(&self) -> Rect

Returns the top-right corner sub-rectangle.

§Returns
  • Rect - The top-right corner patch.
Source

pub fn get_left(&self) -> Rect

Returns the left edge sub-rectangle.

§Returns
  • Rect - The left edge patch.
Source

pub fn get_center(&self) -> Rect

Returns the stretchable center sub-rectangle.

§Returns
  • Rect - The center patch.
Source

pub fn get_right(&self) -> Rect

Returns the right edge sub-rectangle.

§Returns
  • Rect - The right edge patch.
Source

pub fn get_bottom_left(&self) -> Rect

Returns the bottom-left corner sub-rectangle.

§Returns
  • Rect - The bottom-left corner patch.
Source

pub fn get_bottom(&self) -> Rect

Returns the bottom edge sub-rectangle.

§Returns
  • Rect - The bottom edge patch.
Source

pub fn get_bottom_right(&self) -> Rect

Returns the bottom-right corner sub-rectangle.

§Returns
  • Rect - The bottom-right corner patch.
Source

pub fn to_vec(&self) -> Vec<Rect>

Returns the nine patches as a flat slice in reading order.

§Returns
  • Vec<Rect> - The nine patches, top row first then middle then bottom.
Source§

impl NineSliceRects

Source

pub fn get_grid(&self) -> [[Rect; 3]; 3]

Source

pub fn get_mut_grid(&mut self) -> &mut [[Rect; 3]; 3]

Source

pub fn set_grid(&mut self, val: [[Rect; 3]; 3]) -> &mut Self

Source§

impl NineSliceRects

Source

pub fn new(grid: [[Rect; 3]; 3]) -> Self

Trait Implementations§

Source§

impl Clone for NineSliceRects

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 NineSliceRects

Source§

impl Debug for NineSliceRects

Source§

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

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

impl PartialEq for NineSliceRects

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 NineSliceRects

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