FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    PixelRect

    struct · ferroui-base · v0.5.0

    struct PixelRect
    

    Represents a rectangle in device pixels. Integer arithmetic wraps on overflow.

    View source

    Members

    x

    x: i32
    

    The X position.

    Source

    y

    y: i32
    

    The Y position.

    Source

    width

    width: i32
    

    The width.

    Source

    height

    height: i32
    

    The height.

    Source

    new

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

    Initializes a new instance of the PixelRect structure.

    Source

    from_size

    const fn from_size(size: PixelSize) -> Self
    

    Initializes a PixelRect at the origin with the given size.

    Source

    from_position_size

    const fn from_position_size(position: PixelPoint, size: PixelSize) -> Self
    

    Initializes a PixelRect from its position and size.

    Source

    from_points

    const fn from_points(top_left: PixelPoint, bottom_right: PixelPoint) -> Self
    

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

    Source

    position

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

    Gets the position of the rectangle.

    Source

    size

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

    Gets the size of the rectangle.

    Source

    right

    const fn right(self: &Self) -> i32
    

    Gets the right position of the rectangle.

    Source

    bottom

    const fn bottom(self: &Self) -> i32
    

    Gets the bottom position of the rectangle.

    Source

    top_left

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

    Gets the top left point of the rectangle.

    Source

    top_right

    const fn top_right(self: &Self) -> PixelPoint
    

    Gets the top right point of the rectangle.

    Source

    bottom_left

    const fn bottom_left(self: &Self) -> PixelPoint
    

    Gets the bottom left point of the rectangle.

    Source

    bottom_right

    const fn bottom_right(self: &Self) -> PixelPoint
    

    Gets the bottom right point of the rectangle.

    Source

    center

    const fn center(self: &Self) -> PixelPoint
    

    Gets the center point of the rectangle.

    Source

    contains

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

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

    Source

    contains_exclusive

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

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

    Source

    contains_rect

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

    Determines whether the rectangle fully contains another rectangle.

    Source

    center_rect

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

    Centers another rectangle in this rectangle.

    Source

    equals

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

    Returns a boolean indicating whether the rect is equal to the other given rect.

    Source

    intersect

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

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

    Source

    intersects

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

    Determines whether a rectangle intersects with this rectangle.

    Source

    translate

    fn translate(self: &Self, offset: PixelVector) -> PixelRect
    

    Translates the rectangle by an offset.

    Source

    union

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

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

    Source

    with_x

    const fn with_x(self: &Self, x: i32) -> PixelRect
    

    Returns a new PixelRect with the specified X position.

    Source

    with_y

    const fn with_y(self: &Self, y: i32) -> PixelRect
    

    Returns a new PixelRect with the specified Y position.

    Source

    with_width

    const fn with_width(self: &Self, width: i32) -> PixelRect
    

    Returns a new PixelRect with the specified width.

    Source

    with_height

    const fn with_height(self: &Self, height: i32) -> PixelRect
    

    Returns a new PixelRect with the specified height.

    Source

    to_rect

    fn to_rect(self: &Self, scale: f64) -> Rect
    

    Converts the PixelRect to a device-independent Rect using the specified scaling factor.

    Source

    to_rect_vector

    fn to_rect_vector(self: &Self, scale: Vector) -> Rect
    

    Converts the PixelRect to a device-independent Rect using the specified per-axis scaling factor.

    Source

    to_rect_with_dpi

    fn to_rect_with_dpi(self: &Self, dpi: f64) -> Rect
    

    Converts the PixelRect to a device-independent Rect using the specified dots per inch (DPI).

    Source

    to_rect_with_dpi_vector

    fn to_rect_with_dpi_vector(self: &Self, dpi: Vector) -> Rect
    

    Converts the PixelRect to a device-independent Rect using the specified per-axis dots per inch (DPI).

    Source

    from_rect

    fn from_rect(rect: Rect, scale: f64) -> PixelRect
    

    Converts a Rect to device pixels using the specified scaling factor. The top left is truncated and the bottom right is rounded up.

    Source

    from_rect_vector

    fn from_rect_vector(rect: Rect, scale: Vector) -> PixelRect
    

    Converts a Rect to device pixels using the specified per-axis scaling factor.

    Source

    from_rect_with_dpi

    fn from_rect_with_dpi(rect: Rect, dpi: f64) -> PixelRect
    

    Converts a Rect to device pixels using the specified dots per inch (DPI).

    Source

    from_rect_with_dpi_vector

    fn from_rect_with_dpi_vector(rect: Rect, dpi: Vector) -> PixelRect
    

    Converts a Rect to device pixels using the specified per-axis dots per inch (DPI).

    Source

    parse

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

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

    Source

    Trait implementations

    Availability

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