Struct sdl2::rect::Rect [] [src]

pub struct Rect {
    // some fields omitted
}

Immutable rectangle type, consisting of x, y, width and height.

Rectangle invariants:

  • width and height are positive and non-zero.
  • width and height are less than 1<<31 (2,147,483,648).
  • x + width and y + height do not overflow.

These invariants exist in the wrapper because many SDL functions that accept rectangles don't behave predictably if the above conditions aren't met.

Methods

impl Rect
[src]

fn raw(&self) -> *const SDL_Rect

fn raw_from_option(v: Option<&Rect>) -> *const SDL_Rect

fn raw_mut_from_option(v: Option<&mut Rect>) -> *mut SDL_Rect

fn raw_slice(slice: &[Rect]) -> *const SDL_Rect

fn from_ll(raw: SDL_Rect) -> SdlResult<Option<Rect>>

fn new(x: i32, y: i32, width: u32, height: u32) -> SdlResult<Option<Rect>>

Creates a new rectangle.

If width or height is zero, Ok(None) is returned. If the arguments violate any of the other rectangle invariants, an error is returned.

fn new_unwrap(x: i32, y: i32, width: u32, height: u32) -> Rect

Creates a new rectangle. Convenience function that unwraps the result of Rect::new() twice.

Make sure to only use this function if you're certain the rectangle meets all the invariants.

fn offset(&self, x: i32, y: i32) -> SdlResult<Rect>

Offsets the rectangle's x and y coordinates.

If the new rectangle violates any invariants, an error is returned.

fn xywh(&self) -> (i32, i32, u32, u32)

fn x(&self) -> i32

fn y(&self) -> i32

fn width(&self) -> u32

fn height(&self) -> u32

fn from_enclose_points(points: &[Point], clip: Option<Rect>) -> SdlResult<Option<Rect>>

Calculate a minimal rectangle enclosing a set of points.

Returns Ok(None) if there are no points, or no points within the clipping rectangle. Returns an error if the resulting rectangle's dimensions are too large for the points.

fn has_intersection(&self, other: &Rect) -> bool

Determine whether two rectangles intersect.

fn intersect(&self, other: &Rect) -> Option<Rect>

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

fn union(&self, other: &Rect) -> Rect

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

fn intersect_line(&self, start: Point, end: Point) -> Option<(Point, Point)>

Calculate the intersection of a rectangle and line segment. return points of intersection.

Trait Implementations

impl Hash for Rect
[src]

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl Debug for Rect
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl PartialEq for Rect
[src]

fn eq(&self, __arg_0: &Rect) -> bool

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

fn ne(&self, __arg_0: &Rect) -> bool

This method tests for !=.

impl Eq for Rect
[src]

impl Clone for Rect
[src]

fn clone(&self) -> Rect

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl Copy for Rect
[src]

impl Into<(i32, i32, u32, u32)> for Rect
[src]

fn into(self) -> (i32, i32, u32, u32)

Performs the conversion.

impl BitAnd<Rect> for Rect
[src]

Intersect

type Output = Option<Rect>

The resulting type after applying the & operator

fn bitand(self, rhs: Rect) -> Option<Rect>

The method for the & operator

impl<'a> BitAnd<&'a Rect> for Rect
[src]

Intersect

type Output = Option<Rect>

The resulting type after applying the & operator

fn bitand(self, rhs: &Rect) -> Option<Rect>

The method for the & operator

impl<'a> BitAnd<Rect> for &'a Rect
[src]

Intersect

type Output = Option<Rect>

The resulting type after applying the & operator

fn bitand(self, rhs: Rect) -> Option<Rect>

The method for the & operator

impl<'a> BitAnd<&'a Rect> for &'a Rect
[src]

Intersect

type Output = Option<Rect>

The resulting type after applying the & operator

fn bitand(self, rhs: &Rect) -> Option<Rect>

The method for the & operator

impl BitOr<Rect> for Rect
[src]

Union

type Output = Rect

The resulting type after applying the | operator

fn bitor(self, rhs: Rect) -> Rect

The method for the | operator

impl<'a> BitOr<&'a Rect> for Rect
[src]

Union

type Output = Rect

The resulting type after applying the | operator

fn bitor(self, rhs: &Rect) -> Rect

The method for the | operator

impl<'a> BitOr<Rect> for &'a Rect
[src]

Union

type Output = Rect

The resulting type after applying the | operator

fn bitor(self, rhs: Rect) -> Rect

The method for the | operator

impl<'a> BitOr<&'a Rect> for &'a Rect
[src]

Union

type Output = Rect

The resulting type after applying the | operator

fn bitor(self, rhs: &Rect) -> Rect

The method for the | operator