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

pub struct Rect {
    // some fields omitted
}

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

Rectangle invariants:

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

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 Into<(i32, i32, u32, u32)> for Rect

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

impl BitAnd<Rect> for Rect

Intersect

type Output = Option<Rect>

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

impl<'a> BitAnd<&'a Rect> for Rect

Intersect

type Output = Option<Rect>

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

impl<'a> BitAnd<Rect> for &'a Rect

Intersect

type Output = Option<Rect>

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

impl<'a> BitAnd<&'a Rect> for &'a Rect

Intersect

type Output = Option<Rect>

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

impl BitOr<Rect> for Rect

Union

type Output = Rect

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

impl<'a> BitOr<&'a Rect> for Rect

Union

type Output = Rect

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

impl<'a> BitOr<Rect> for &'a Rect

Union

type Output = Rect

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

impl<'a> BitOr<&'a Rect> for &'a Rect

Union

type Output = Rect

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

Derived Implementations

impl Hash for Rect

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

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

impl Debug for Rect

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

impl PartialEq for Rect

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

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

impl Eq for Rect

impl Clone for Rect

fn clone(&self) -> Rect

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

impl Copy for Rect