pub struct Rectangle { /* private fields */ }
Expand description
Rectangle
specifies an area in a coordinate space that is defined an upper-left point,
as defined by x
and y
, and the dimensions, defined by the Dimension
object.
Implementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn new(x: i32, y: i32, dim: Dimension) -> Rectangle
pub fn new(x: i32, y: i32, dim: Dimension) -> Rectangle
Creates a new Rect
whose upper-left corner is defined by x
and y
, and whose width
and height
are defined by the Dimension
type.
Sourcepub fn set_x(&mut self, x: i32)
pub fn set_x(&mut self, x: i32)
Moves this Rectangle
horizontally to the location specified by x.
Sourcepub fn set_y(&mut self, y: i32)
pub fn set_y(&mut self, y: i32)
Moves this Rectangle
vertically to the location specified by y.
Sourcepub fn set_location(&mut self, x: i32, y: i32)
pub fn set_location(&mut self, x: i32, y: i32)
Moves this Rectangle
to the location specified by x and y.
Sourcepub fn dim(&self) -> &Dimension
pub fn dim(&self) -> &Dimension
Returns an immutable reference to the associated Dimension
object.
Sourcepub fn dim_mut(&mut self) -> &mut Dimension
pub fn dim_mut(&mut self) -> &mut Dimension
Returns a mutable reference to the associated Dimension
object.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if width
or height
of the Rectangle
is 0, and false
otherwise.
Padding is not included in the check.
Sourcepub fn contains(&self, rect: &Rectangle) -> bool
pub fn contains(&self, rect: &Rectangle) -> bool
Checks whether or not this Rectangle
entirely contains the specified Rectangle
.
Padding is not included in the check.
Sourcepub fn intersects(&self, rect: &Rectangle) -> bool
pub fn intersects(&self, rect: &Rectangle) -> bool
Checks whether or not this Rectangle
and the specified Rectangle
intersect.
Padding is not included in the check.
Sourcepub fn union(&self, rect: &Rectangle, id: Option<isize>) -> Self
pub fn union(&self, rect: &Rectangle, id: Option<isize>) -> Self
Computes the union of this Rectangle
with the specified Rectangle
.
rect
specifies the second rectangle to use for the union.
id
will be used as new identifier for the dimension included the returned Rectangle
.
An identifier is autogenerated if if None
is specified.
The greater padding of the source Rectangle
s is applied to the returned Rectangle
.
Returns a new Rectangle
that represents the union of the two rectangles.