pub struct PixelRect {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}Expand description
Represents a rectangle in device pixels. Integer arithmetic wraps on overflow.
Fields§
§x: i32The X position.
y: i32The Y position.
width: i32The width.
height: i32The height.
Implementations§
Source§impl PixelRect
impl PixelRect
Sourcepub const fn new(x: i32, y: i32, width: i32, height: i32) -> Self
pub const fn new(x: i32, y: i32, width: i32, height: i32) -> Self
Initializes a new instance of the PixelRect structure.
Sourcepub const fn from_size(size: PixelSize) -> Self
pub const fn from_size(size: PixelSize) -> Self
Initializes a PixelRect at the origin with the given size.
Sourcepub const fn from_position_size(position: PixelPoint, size: PixelSize) -> Self
pub const fn from_position_size(position: PixelPoint, size: PixelSize) -> Self
Initializes a PixelRect from its position and size.
Sourcepub const fn from_points(top_left: PixelPoint, bottom_right: PixelPoint) -> Self
pub const fn from_points(top_left: PixelPoint, bottom_right: PixelPoint) -> Self
Initializes a PixelRect from its top left and bottom right corners.
Sourcepub const fn position(&self) -> PixelPoint
pub const fn position(&self) -> PixelPoint
Gets the position of the rectangle.
Sourcepub const fn top_left(&self) -> PixelPoint
pub const fn top_left(&self) -> PixelPoint
Gets the top left point of the rectangle.
Sourcepub const fn top_right(&self) -> PixelPoint
pub const fn top_right(&self) -> PixelPoint
Gets the top right point of the rectangle.
Sourcepub const fn bottom_left(&self) -> PixelPoint
pub const fn bottom_left(&self) -> PixelPoint
Gets the bottom left point of the rectangle.
Sourcepub const fn bottom_right(&self) -> PixelPoint
pub const fn bottom_right(&self) -> PixelPoint
Gets the bottom right point of the rectangle.
Sourcepub const fn center(&self) -> PixelPoint
pub const fn center(&self) -> PixelPoint
Gets the center point of the rectangle.
Sourcepub const fn contains(&self, p: PixelPoint) -> bool
pub const fn contains(&self, p: PixelPoint) -> bool
Determines whether a point is in the bounds of the rectangle (edges inclusive).
Sourcepub const fn contains_exclusive(&self, p: PixelPoint) -> bool
pub const fn contains_exclusive(&self, p: PixelPoint) -> bool
Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle’s bottom/right edge.
Sourcepub const fn contains_rect(&self, r: PixelRect) -> bool
pub const fn contains_rect(&self, r: PixelRect) -> bool
Determines whether the rectangle fully contains another rectangle.
Sourcepub const fn center_rect(&self, rect: PixelRect) -> PixelRect
pub const fn center_rect(&self, rect: PixelRect) -> PixelRect
Centers another rectangle in this rectangle.
Sourcepub const fn equals(&self, other: PixelRect) -> bool
pub const fn equals(&self, other: PixelRect) -> bool
Returns a boolean indicating whether the rect is equal to the other given rect.
Sourcepub const fn intersect(&self, rect: PixelRect) -> PixelRect
pub const fn intersect(&self, rect: PixelRect) -> PixelRect
Gets the intersection of two rectangles, or an empty (default) rectangle if they do not overlap.
Sourcepub const fn intersects(&self, rect: PixelRect) -> bool
pub const fn intersects(&self, rect: PixelRect) -> bool
Determines whether a rectangle intersects with this rectangle.
Sourcepub fn translate(&self, offset: PixelVector) -> PixelRect
pub fn translate(&self, offset: PixelVector) -> PixelRect
Translates the rectangle by an offset.
Sourcepub fn union(&self, rect: PixelRect) -> PixelRect
pub fn union(&self, rect: PixelRect) -> PixelRect
Gets the union of two rectangles. A rectangle whose width and height are both zero is ignored.
Sourcepub const fn with_x(&self, x: i32) -> PixelRect
pub const fn with_x(&self, x: i32) -> PixelRect
Returns a new PixelRect with the specified X position.
Sourcepub const fn with_y(&self, y: i32) -> PixelRect
pub const fn with_y(&self, y: i32) -> PixelRect
Returns a new PixelRect with the specified Y position.
Sourcepub const fn with_width(&self, width: i32) -> PixelRect
pub const fn with_width(&self, width: i32) -> PixelRect
Returns a new PixelRect with the specified width.
Sourcepub const fn with_height(&self, height: i32) -> PixelRect
pub const fn with_height(&self, height: i32) -> PixelRect
Returns a new PixelRect with the specified height.
Sourcepub fn to_rect_vector(&self, scale: Vector) -> Rect
pub fn to_rect_vector(&self, scale: Vector) -> Rect
Sourcepub fn to_rect_with_dpi(&self, dpi: f64) -> Rect
pub fn to_rect_with_dpi(&self, dpi: f64) -> Rect
Sourcepub fn to_rect_with_dpi_vector(&self, dpi: Vector) -> Rect
pub fn to_rect_with_dpi_vector(&self, dpi: Vector) -> Rect
Sourcepub fn from_rect(rect: Rect, scale: f64) -> PixelRect
pub 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.
Sourcepub fn from_rect_vector(rect: Rect, scale: Vector) -> PixelRect
pub fn from_rect_vector(rect: Rect, scale: Vector) -> PixelRect
Converts a Rect to device pixels using the specified per-axis scaling factor.
Sourcepub fn from_rect_with_dpi(rect: Rect, dpi: f64) -> PixelRect
pub fn from_rect_with_dpi(rect: Rect, dpi: f64) -> PixelRect
Converts a Rect to device pixels using the specified dots per inch (DPI).
Trait Implementations§
impl Copy for PixelRect
impl Eq for PixelRect
Source§impl MarkupTyped for PixelRect
impl MarkupTyped for PixelRect
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
impl StructuralPartialEq for PixelRect
Auto Trait Implementations§
impl Freeze for PixelRect
impl RefUnwindSafe for PixelRect
impl Send for PixelRect
impl Sync for PixelRect
impl Unpin for PixelRect
impl UnsafeUnpin for PixelRect
impl UnwindSafe for PixelRect
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more