pub struct Region {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}Expand description
An axis-aligned rectangle of pixels, in image coordinates.
The origin is the top-left corner; x grows right and y grows down. A
region with zero width or height is empty and legal to represent — it is
what demand propagation produces when an op needs nothing from an input.
Edge accessors return u64 so that a region touching the far edge of the
coordinate space cannot overflow during intersection math.
Fields§
§x: u32Distance from the left edge of the image, in pixels.
y: u32Distance from the top edge of the image, in pixels.
width: u32Width in pixels; may be zero.
height: u32Height in pixels; may be zero.
Implementations§
Source§impl Region
impl Region
Sourcepub const fn new(x: u32, y: u32, width: u32, height: u32) -> Region
pub const fn new(x: u32, y: u32, width: u32, height: u32) -> Region
Construct a region from its origin and size.
Sourcepub const fn from_size(width: u32, height: u32) -> Region
pub const fn from_size(width: u32, height: u32) -> Region
A region covering width × height pixels at the origin.
Sourcepub const fn pixel_count(self) -> u64
pub const fn pixel_count(self) -> u64
The number of pixels in the region.
Sourcepub const fn contains(self, other: Region) -> bool
pub const fn contains(self, other: Region) -> bool
Whether other lies entirely within self.
An empty region is contained by any region, including another empty one.
Sourcepub fn intersect(self, other: Region) -> Region
pub fn intersect(self, other: Region) -> Region
The overlap between two regions, or Region::EMPTY if they are
disjoint.