FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    Rect

    struct · ferroui-base · v0.5.0

    struct Rect
    

    Defines a rectangle.

    View source

    Members

    x

    x: f64
    

    The X position.

    Source

    y

    y: f64
    

    The Y position.

    Source

    width

    width: f64
    

    The width.

    Source

    height

    height: f64
    

    The height.

    Source

    new

    const fn new(x: f64, y: f64, width: f64, height: f64) -> Self
    

    Initializes a new instance of the Rect structure.

    Source

    from_size

    const fn from_size(size: Size) -> Self
    

    Initializes a Rect at the origin with the given size.

    Source

    from_position_size

    const fn from_position_size(position: Point, size: Size) -> Self
    

    Initializes a Rect from its position and size.

    Source

    from_points

    fn from_points(top_left: Point, bottom_right: Point) -> Self
    

    Initializes a Rect from its top left and bottom right corners.

    Source

    position

    const fn position(self: &Self) -> Point
    

    Gets the position of the rectangle.

    Source

    size

    const fn size(self: &Self) -> Size
    

    Gets the size of the rectangle.

    Source

    right

    fn right(self: &Self) -> f64
    

    Gets the right position of the rectangle.

    Source

    bottom

    fn bottom(self: &Self) -> f64
    

    Gets the bottom position of the rectangle.

    Source

    left

    const fn left(self: &Self) -> f64
    

    Gets the left position.

    Source

    top

    const fn top(self: &Self) -> f64
    

    Gets the top position.

    Source

    top_left

    const fn top_left(self: &Self) -> Point
    

    Gets the top left point of the rectangle.

    Source

    top_right

    fn top_right(self: &Self) -> Point
    

    Gets the top right point of the rectangle.

    Source

    bottom_left

    fn bottom_left(self: &Self) -> Point
    

    Gets the bottom left point of the rectangle.

    Source

    bottom_right

    fn bottom_right(self: &Self) -> Point
    

    Gets the bottom right point of the rectangle.

    Source

    center

    fn center(self: &Self) -> Point
    

    Gets the center point of the rectangle.

    Source

    contains

    fn contains(self: &Self, p: Point) -> bool
    

    Determines whether a point is in the bounds of the rectangle (edges inclusive).

    Source

    contains_exclusive

    fn contains_exclusive(self: &Self, p: Point) -> bool
    

    Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.

    Source

    contains_rect

    fn contains_rect(self: &Self, r: Rect) -> bool
    

    Determines whether the rectangle fully contains another rectangle.

    Source

    center_rect

    fn center_rect(self: &Self, rect: Rect) -> Rect
    

    Centers another rectangle in this rectangle.

    Source

    inflate

    fn inflate(self: &Self, thickness: f64) -> Rect
    

    Inflates the rectangle by the same amount on every side.

    Source

    inflate_thickness

    fn inflate_thickness(self: &Self, thickness: Thickness) -> Rect
    

    Inflates the rectangle.

    Source

    deflate

    fn deflate(self: &Self, thickness: f64) -> Rect
    

    Deflates the rectangle by the same amount on every side.

    Source

    deflate_thickness

    fn deflate_thickness(self: &Self, thickness: Thickness) -> Rect
    

    Deflates the rectangle by a Thickness. The deflated rectangle size cannot be less than 0.

    Source

    equals

    fn equals(self: &Self, other: Rect) -> bool
    

    Returns a boolean indicating whether the rect is equal to the other given rect (exact comparison).

    Source

    intersect

    fn intersect(self: &Self, rect: Rect) -> Rect
    

    Gets the intersection of two rectangles, or an empty (default) rectangle if they do not overlap.

    Source

    intersects

    fn intersects(self: &Self, rect: Rect) -> bool
    

    Determines whether a rectangle intersects with this rectangle.

    Source

    transform_to_aabb

    fn transform_to_aabb(self: &Self, matrix: Matrix) -> Rect
    

    Returns the axis-aligned bounding box of a transformed rectangle.

    Source

    translate

    fn translate(self: &Self, offset: Vector) -> Rect
    

    Translates the rectangle by an offset.

    Source

    normalize

    fn normalize(self: &Self) -> Rect
    

    Normalizes the rectangle so both the width and height are positive, without changing its location: positive-size rects are returned unchanged, negative sizes are flipped. A rect with any NaN edge becomes the default rect.

    Source

    union

    fn union(self: &Self, rect: Rect) -> Rect
    

    Gets the union of two rectangles. A rectangle whose width and height are both zero is ignored.

    Source

    union_optional

    fn union_optional(left: Option<Rect>, right: Option<Rect>) -> Option<Rect>
    

    Union of two optional rectangles; a missing side yields the other side.

    Source

    with_x

    const fn with_x(self: &Self, x: f64) -> Rect
    

    Returns a new Rect with the specified X position.

    Source

    with_y

    const fn with_y(self: &Self, y: f64) -> Rect
    

    Returns a new Rect with the specified Y position.

    Source

    with_width

    const fn with_width(self: &Self, width: f64) -> Rect
    

    Returns a new Rect with the specified width.

    Source

    with_height

    const fn with_height(self: &Self, height: f64) -> Rect
    

    Returns a new Rect with the specified height.

    Source

    parse

    fn parse(s: &str) -> Result<Self, FormatError>
    

    Parses a Rect string ("x, y, width, height").

    Source

    is_empty

    fn is_empty(self: &Self) -> bool
    

    This method should be used internally to check for the rect emptiness. Once a dedicated "empty" value exists this is the single place to update.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • From<Rect>
    • BatchValue
    • MarkupTyped
    • ValueTypeRegistration
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • Mul<Vector>
    • Mul<f64>
    • Div<Vector>
    • MulAssign<Vector>
    • MulAssign<f64>
    • DivAssign<Vector>
    • FromStr
    • Display

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.