#[repr(C)]
pub struct Rectangle<T = f32> { /* private fields */ }
Expand description

A struct representing an axis-aligned rectangle. Two points are stored: the top left vertex, and the bottom right vertex.

Implementations

Constructs a new Rectangle. The top left vertex must be above and to the left of the bottom right vertex.

Constructs a new Rectangle. The top left vertex must be above and to the left of the bottom right vertex.

Returns a reference to the top left vertex.

Returns a reference to the bottom right vertex.

Returns a vector representing the top right vertex.

Returns a vector representing the bottom left vertex.

Returns the width of the rectangle.

Returns the height of the rectangle.

Returns a Vector2 containing the width and height of the rectangle.

Returns true if the specified point is inside this rectangle. This is inclusive of the top and left coordinates, and exclusive of the bottom and right coordinates.

Finds the intersection of two rectangles – in other words, the area that is common to both of them.

If there is no common area between the two rectangles, then this function will return None.

A constant representing a rectangle with position (0, 0) and zero area. Each component is set to zero.

Returns true if the rectangle has zero area.

Returns a new rectangle, whose vertices are offset relative to the current rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.

Returns a new rectangle, whose vertices are negatively offset relative to the current rectangle by the specified amount. This is equivalent to subtracting the specified vector to each vertex.

Returns a new rectangle where the coordinates have been cast to f32 values, using the as operator.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.