Struct tiny_skia_path::Rect
source · pub struct Rect { /* private fields */ }
Expand description
A rectangle defined by left, top, right and bottom edges.
Can have zero width and/or height. But not a negative one.
§Guarantees
- All values are finite.
- Left edge is <= right.
- Top edge is <= bottom.
- Width and height are <= f32::MAX.
Implementations§
source§impl Rect
impl Rect
sourcepub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Option<Self>
pub fn from_ltrb(left: f32, top: f32, right: f32, bottom: f32) -> Option<Self>
Creates new Rect
.
sourcepub fn round(&self) -> Option<IntRect>
pub fn round(&self) -> Option<IntRect>
Converts into an IntRect
by adding 0.5 and discarding the fractional portion.
Width and height are guarantee to be >= 1.
sourcepub fn round_out(&self) -> Option<IntRect>
pub fn round_out(&self) -> Option<IntRect>
Converts into an IntRect
rounding outwards.
Width and height are guarantee to be >= 1.
sourcepub fn intersect(&self, other: &Self) -> Option<Self>
pub fn intersect(&self, other: &Self) -> Option<Self>
Returns an intersection of two rectangles.
Returns None
otherwise.
sourcepub fn from_points(points: &[Point]) -> Option<Self>
pub fn from_points(points: &[Point]) -> Option<Self>
Creates a Rect from Point array.
Returns None if count is zero or if Point array contains an infinity or NaN.
sourcepub fn inset(&self, dx: f32, dy: f32) -> Option<Self>
pub fn inset(&self, dx: f32, dy: f32) -> Option<Self>
Insets the rectangle by the specified offset.
sourcepub fn outset(&self, dx: f32, dy: f32) -> Option<Self>
pub fn outset(&self, dx: f32, dy: f32) -> Option<Self>
Outsets the rectangle by the specified offset.
sourcepub fn transform(&self, ts: Transform) -> Option<Self>
pub fn transform(&self, ts: Transform) -> Option<Self>
Transforms the rect using the provided Transform
.
This method is expensive.
sourcepub fn bbox_transform(&self, bbox: NonZeroRect) -> Self
pub fn bbox_transform(&self, bbox: NonZeroRect) -> Self
Applies a bounding box transform.
sourcepub fn to_non_zero_rect(&self) -> Option<NonZeroRect>
pub fn to_non_zero_rect(&self) -> Option<NonZeroRect>
Converts into NonZeroRect
.
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)