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.
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.
Sourcepub fn source_rects(&self, source: Rect) -> NineSliceRects
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.
Sourcepub fn dest_rects(&self, dest: Rect) -> NineSliceRects
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.