pub struct PixelRect {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}Expand description
A rectangle in physical pixels, relative to the top left of the surface.
Every rectangle this library produces is non-empty and clamped to the
surface it was computed for, so width and height are at least one.
Fields§
§x: u32Distance from the left edge of the surface, in physical pixels.
y: u32Distance from the top edge of the surface, in physical pixels.
width: u32Width in physical pixels.
height: u32Height in physical pixels.
Implementations§
Source§impl PixelRect
impl PixelRect
Sourcepub fn union(self, other: PixelRect) -> PixelRect
pub fn union(self, other: PixelRect) -> PixelRect
Returns the smallest rectangle covering both operands.
An operand with no area is ignored, so the union of
PixelRect::default() with other is other.
Sourcepub fn intersect(self, other: PixelRect) -> Option<PixelRect>
pub fn intersect(self, other: PixelRect) -> Option<PixelRect>
Returns the overlapping part of two rectangles, or None when they do
not overlap.
Sourcepub fn contains_rect(self, other: PixelRect) -> bool
pub fn contains_rect(self, other: PixelRect) -> bool
Returns true when other lies entirely inside this rectangle.
The edges are inclusive, so a rectangle with no width or height counts as inside when it sits on the boundary.
Sourcepub fn from_logical(
rect: Rect,
scale: f32,
surface_width: u32,
surface_height: u32,
) -> Option<PixelRect>
pub fn from_logical( rect: Rect, scale: f32, surface_width: u32, surface_height: u32, ) -> Option<PixelRect>
Returns the smallest pixel rectangle covering every physical pixel the logical rectangle touches, clamped to the surface.
The minimum corner is rounded down and the maximum corner is rounded up,
so a rectangle that covers part of a pixel still claims that pixel.
Returns None when the result would be empty, which includes a
rectangle entirely outside the surface.
NaN and infinite coordinates, and a scale that is not positive and finite, are treated as empty.