PixelRect
struct · ferroui-base · v0.5.0
struct PixelRect
Represents a rectangle in device pixels. Integer arithmetic wraps on overflow.
Members
xywidthheightnewfrom_sizefrom_position_sizefrom_pointspositionsizerightbottomtop_lefttop_rightbottom_leftbottom_rightcentercontainscontains_exclusivecontains_rectcenter_rectequalsintersectintersectstranslateunionwith_xwith_ywith_widthwith_heightto_rectto_rect_vectorto_rect_with_dpito_rect_with_dpi_vectorfrom_rectfrom_rect_vectorfrom_rect_with_dpifrom_rect_with_dpi_vectorparse
x
x: i32
The X position.
y
y: i32
The Y position.
width
width: i32
The width.
height
height: i32
The height.
new
const fn new(x: i32, y: i32, width: i32, height: i32) -> Self
Initializes a new instance of the PixelRect structure.
from_size
const fn from_size(size: PixelSize) -> Self
Initializes a PixelRect at the origin with the given size.
from_position_size
const fn from_position_size(position: PixelPoint, size: PixelSize) -> Self
Initializes a PixelRect from its position and size.
from_points
const fn from_points(top_left: PixelPoint, bottom_right: PixelPoint) -> Self
Initializes a PixelRect from its top left and bottom right corners.
position
const fn position(self: &Self) -> PixelPoint
Gets the position of the rectangle.
size
const fn size(self: &Self) -> PixelSize
Gets the size of the rectangle.
right
const fn right(self: &Self) -> i32
Gets the right position of the rectangle.
bottom
const fn bottom(self: &Self) -> i32
Gets the bottom position of the rectangle.
top_left
const fn top_left(self: &Self) -> PixelPoint
Gets the top left point of the rectangle.
top_right
const fn top_right(self: &Self) -> PixelPoint
Gets the top right point of the rectangle.
bottom_left
const fn bottom_left(self: &Self) -> PixelPoint
Gets the bottom left point of the rectangle.
bottom_right
const fn bottom_right(self: &Self) -> PixelPoint
Gets the bottom right point of the rectangle.
center
const fn center(self: &Self) -> PixelPoint
Gets the center point of the rectangle.
contains
const fn contains(self: &Self, p: PixelPoint) -> bool
Determines whether a point is in the bounds of the rectangle (edges inclusive).
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.
contains_rect
const fn contains_rect(self: &Self, r: PixelRect) -> bool
Determines whether the rectangle fully contains another rectangle.
center_rect
const fn center_rect(self: &Self, rect: PixelRect) -> PixelRect
Centers another rectangle in this rectangle.
equals
const fn equals(self: &Self, other: PixelRect) -> bool
Returns a boolean indicating whether the rect is equal to the other given rect.
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.
intersects
const fn intersects(self: &Self, rect: PixelRect) -> bool
Determines whether a rectangle intersects with this rectangle.
translate
fn translate(self: &Self, offset: PixelVector) -> PixelRect
Translates the rectangle by an offset.
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.
with_x
const fn with_x(self: &Self, x: i32) -> PixelRect
Returns a new PixelRect with the specified X position.
with_y
const fn with_y(self: &Self, y: i32) -> PixelRect
Returns a new PixelRect with the specified Y position.
with_width
const fn with_width(self: &Self, width: i32) -> PixelRect
Returns a new PixelRect with the specified width.
with_height
const fn with_height(self: &Self, height: i32) -> PixelRect
Returns a new PixelRect with the specified height.
to_rect
fn to_rect(self: &Self, scale: f64) -> Rect
Converts the PixelRect to a device-independent Rect using the
specified scaling factor.
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.
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).
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).
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.
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.
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).
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).
parse
fn parse(s: &str) -> Result<Self, FormatError>
Parses a PixelRect string ("x, y, width, height").
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeResourceKeyObjectPropertyValueAnyValueClassDefaultsBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedToStringErasedDestructorIntoEitherMarkupTypedValueTypeRegistrationCloneCopyDebugStructuralPartialEqPartialEqEqHashDefaultFromStrDisplay
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.