Struct sdl2::rect::Point

source ·
pub struct Point { /* private fields */ }
Expand description

Immutable point type, consisting of x and y.

Implementations§

source§

impl Point

source

pub fn new(x: i32, y: i32) -> Point

Creates a new point from the given coordinates.

source

pub fn from_ll(raw: SDL_Point) -> Point

source

pub fn raw_slice(slice: &[Point]) -> *const SDL_Point

source

pub fn raw(&self) -> *const SDL_Point

source

pub fn offset(self, x: i32, y: i32) -> Point

Returns a new point by shifting this point’s coordinates by the given x and y values.

source

pub fn scale(self, f: i32) -> Point

Returns a new point by multiplying this point’s coordinates by the given scale factor.

source

pub fn x(self) -> i32

Returns the x-coordinate of this point.

source

pub fn y(self) -> i32

Returns the y-coordinate of this point.

Trait Implementations§

source§

impl Add for Point

§

type Output = Point

The resulting type after applying the + operator.
source§

fn add(self, rhs: Point) -> Point

Performs the + operation. Read more
source§

impl AddAssign for Point

source§

fn add_assign(&mut self, rhs: Point)

Performs the += operation. Read more
source§

impl AsMut<SDL_Point> for Point

source§

fn as_mut(&mut self) -> &mut SDL_Point

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<SDL_Point> for Point

source§

fn as_ref(&self) -> &SDL_Point

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Point

source§

fn clone(&self) -> Point

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Point

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl DerefMut for Point

source§

fn deref_mut(&mut self) -> &mut SDL_Point

Example
use sdl2::rect::Point;
let mut point = Point::new(2, 3);
point.x = 4;
assert_eq!(4, point.x);
source§

impl Div<i32> for Point

§

type Output = Point

The resulting type after applying the / operator.
source§

fn div(self, rhs: i32) -> Point

Performs the / operation. Read more
source§

impl DivAssign<i32> for Point

source§

fn div_assign(&mut self, rhs: i32)

Performs the /= operation. Read more
source§

impl From<(i32, i32)> for Point

source§

fn from((x, y): (i32, i32)) -> Point

Converts to this type from the input type.
source§

impl From<SDL_Point> for Point

source§

fn from(prim: SDL_Point) -> Point

Converts to this type from the input type.
source§

impl Hash for Point

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

Feeds a slice of this type into the given Hasher. Read more
source§

impl Into<(i32, i32)> for Point

source§

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

Converts this type into the (usually inferred) input type.
source§

impl Into<SDL_Point> for Point

source§

fn into(self) -> SDL_Point

Converts this type into the (usually inferred) input type.
source§

impl Mul<i32> for Point

§

type Output = Point

The resulting type after applying the * operator.
source§

fn mul(self, rhs: i32) -> Point

Performs the * operation. Read more
source§

impl MulAssign<i32> for Point

source§

fn mul_assign(&mut self, rhs: i32)

Performs the *= operation. Read more
source§

impl Neg for Point

§

type Output = Point

The resulting type after applying the - operator.
source§

fn neg(self) -> Point

Performs the unary - operation. Read more
source§

impl PartialEq for Point

source§

fn eq(&self, other: &Point) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

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

impl Sub for Point

§

type Output = Point

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Point) -> Point

Performs the - operation. Read more
source§

impl SubAssign for Point

source§

fn sub_assign(&mut self, rhs: Point)

Performs the -= operation. Read more
source§

impl Sum for Point

source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Method which takes an iterator and generates Self from the elements by “summing up” the items.
source§

impl Deref for Point

source§

fn deref(&self) -> &SDL_Point

Example
use sdl2::rect::Point;
let point = Point::new(2, 3);
assert_eq!(2, point.x);
§

type Target = SDL_Point

The resulting type after dereferencing.
source§

impl Copy for Point

source§

impl Eq for Point

Auto Trait Implementations§

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnwindSafe for Point

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.