Struct pix_engine::shape::Rect [−][src]
#[repr(transparent)]pub struct Rect<T = i32>(_);
Expand description
A Rectangle
positioned at (x, y)
with width
and height
. A square is a Rectangle
where
width
and height
are equal.
Please see the module-level documentation for examples.
Implementations
Returns Rect
as [x, y, width, height]
.
Example
let r = rect!(5, 10, 100, 100);
assert_eq!(r.as_array(), [5, 10, 100, 100]);
Returns Rect
as a byte slice &[x, y, width, height]
.
Example
let r = rect!(5, 10, 100, 100);
assert_eq!(r.as_bytes(), &[5, 10, 100, 100]);
Returns Rect
as a mutable byte slice &mut [x, y, width, height]
.
Example
let mut r = rect!(5, 10, 100, 100);
for p in r.as_bytes_mut() {
*p += 5;
}
assert_eq!(r.as_bytes(), &[10, 15, 105, 105]);
Sets the height
of the rectangle.
Constructs a Rect
at position Point with width
and height
.
Constructs a square Rect
at position Point with size
.
Constructs a Rect
centered at position (x, y)
with width
and height
.
Example
let r = Rect::from_center([50, 50], 100, 100);
assert_eq!(r.as_array(), [0, 0, 100, 100]);
Constructs a square Rect
centered at position (x, y)
with size
.
Example
let s = Rect::square_from_center([50, 50], 100);
assert_eq!(s.as_array(), [0, 0, 100, 100]);
Reposition the the rectangle.
Offsets a rectangle by shifting coordinates by given amount.
Offsets a rectangle’s size by shifting coordinates by given amount.
Grows a rectangle by a given size.
Shrinks a rectangle by a given size.
Set the vertical position of the bottom edge.
Returns the bottom-left position as Point.
Returns the bottom-right position as Point.
Returns the four Points that compose this Rect
as [top_left, top_right, bottom_right, bottom_left]
.
Converts Rect < T > to Rect < U >.
Returns Rect < T > with the nearest integers to the numbers. Round half-way cases away from 0.0.
Returns Rect < T > with the largest integers less than or equal to the numbers.
Trait Implementations
Returns whether this rectangle contains a given Point.
Returns whether this rectangle completely contains another rectangle.
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Creates a value from an iterator. Read more
Returns the closest intersection point with a given line and distance along the line or
None
if there is no intersection.
Returns whether this rectangle intersects with another rectangle.
Auto Trait Implementations
impl<T> RefUnwindSafe for Rect<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Rect<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more