Struct ggez::graphics::Rect []

pub struct Rect { /* fields omitted */ }

A rectangle.

Methods

impl Rect

Creates a new rectangle from the given values.

The width and height are clamped to ensure that the right and bottom sides of the rectangle does not exceed i32::max_value(). (The value 2147483647, the maximal positive size of an i32)

This means that the rect size will behave oddly if you move it very far to the right or downwards on the screen.

Creates a new rectangle centered on the given position.

The width and height are clamped to ensure that the right and bottom sides of the rectangle does not exceed i32::max_value(). (The value 2147483647, the maximal positive size of an i32)

This means that the rect size will behave oddly if you move it very far to the right or downwards on the screen.

The horizontal position of this rectangle.

The vertical position of this rectangle.

The width of this rectangle.

The height of this rectangle.

Returns the width and height of this rectangle.

Sets the horizontal position of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Sets the vertical position of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Sets the width of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Sets the height of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Returns the x-position of the left side of this rectangle.

Returns the x-position of the right side of this rectangle.

Returns the y-position of the top side of this rectangle.

Returns the y-position of the bottom side of this rectangle.

Returns the center position of this rectangle.

Note that if the width or height is not a multiple of two, the center will be rounded down.

Example

use sdl2::rect::{Rect,Point};
let rect = Rect::new(1,0,2,3);
assert_eq!(Point::new(2,1),rect.center());

Returns the top-left corner of this rectangle.

Example

use sdl2::rect::{Rect, Point};
let rect = Rect::new(1, 0, 2, 3);
assert_eq!(Point::new(1, 0), rect.top_left());

Returns the top-right corner of this rectangle.

Example

use sdl2::rect::{Rect, Point};
let rect = Rect::new(1, 0, 2, 3);
assert_eq!(Point::new(3, 0), rect.top_right());

Returns the bottom-left corner of this rectangle.

Example

use sdl2::rect::{Rect, Point};
let rect = Rect::new(1, 0, 2, 3);
assert_eq!(Point::new(1, 3), rect.bottom_left());

Returns the bottom-right corner of this rectangle.

Example

use sdl2::rect::{Rect, Point};
let rect = Rect::new(1, 0, 2, 3);
assert_eq!(Point::new(3, 3), rect.bottom_right());

Sets the position of the right side of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Sets the position of the bottom side of this rectangle to the given value, clamped to be less than or equal to i32::max_value() / 2.

Centers the rectangle on the given point.

Move this rect and clamp the positions to prevent over/underflow. This also clamps the size to prevent overflow.

Moves this rect to the given position after clamping the values.

Resizes this rect to the given size after clamping the values.

Checks whether this rect contains a given point.

Returns the underlying C Rect.

Calculate a minimal rectangle enclosing a set of points. If a clipping rectangle is given, only points that are within it will be considered.

Determine whether two rectangles intersect.

Calculate the intersection of two rectangles. The bitwise AND operator & can also be used.

Calculate the union of two rectangles. The bitwise OR operator | can also be used.

Calculates the intersection of a rectangle and a line segment and returns the points of their intersection.

Trait Implementations

impl Eq for Rect

impl BitOr<Rect> for Rect

impl Hash for Rect

impl Debug for Rect

Formats the value using the given formatter.

impl PartialEq<Rect> for Rect

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

This method tests for !=.

impl From<(i32, i32, u32, u32)> for Rect

Performs the conversion.

impl Into<(i32, i32, u32, u32)> for Rect

Performs the conversion.

impl Copy for Rect

impl BitAnd<Rect> for Rect

impl Clone for Rect

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more