TileRect

Struct TileRect 

Source
pub struct TileRect {
    pub position: Vector2<i32>,
    pub size: Vector2<i32>,
}
Expand description

This is a variation of Rect that is specifically designed for use with TileMap. While the y-axis of Rect points downward to match the y-axis of UI, the y-axis of TileRect points upward to match the y-axis of TileMap, TileSet, and TileMapBrush.

Unlike Rect, TileRect is designed to contain a WxH region of tiles, which means that position + size is not considered to be a point contained in the rect. A point is only contained in the rect if its entire 1x1 area is contained in the rect, so the left-top corner of the rect is position + size - (1,1).

Fields§

§position: Vector2<i32>

The left-bottom corner of the rect.

§size: Vector2<i32>

The width and height of the rect.

Implementations§

Source§

impl TileRect

Source

pub fn new(x: i32, y: i32, w: i32, h: i32) -> Self

Creates a new rectangle from X, Y, width, height.

Source

pub fn iter(&self) -> RectIter

Iterate over the cells contained within this rect.

Source

pub fn from_points(p0: Vector2<i32>, p1: Vector2<i32>) -> Self

Create a new rectangle from two diagonally opposite corner points. In other words, create the smallest rectangle containing both given points.

Source

pub fn with_position(self, position: Vector2<i32>) -> Self

Sets the new position of the rectangle.

Source

pub fn with_size(self, size: Vector2<i32>) -> Self

Sets the new size of the rectangle.

Source

pub fn inflate(&self, dw: i32, dh: i32) -> Self

Inflates the rectangle by the given amounts. It offsets the rectangle by (-dw, -dh) and increases its size by (2 * dw, 2 * dh).

Source

pub fn deflate(&self, dw: i32, dh: i32) -> OptionTileRect

Deflates the rectangle by the given amounts. It offsets the rectangle by (dw, dh) and decreases its size by (2 * dw, 2 * dh).

Source

pub fn contains(&self, pt: Vector2<i32>) -> bool

Checks if the given point lies within the bounds of the rectangle.

Source

pub fn center(&self) -> Vector2<i32>

Returns center point of the rectangle.

Source

pub fn push(&mut self, p: Vector2<i32>)

Extends the rectangle to contain the given point.

Source

pub fn clip_by(&self, other: TileRect) -> OptionTileRect

Clips the rectangle by some other rectangle and returns a new rectangle that corresponds to the intersection of both rectangles. If the rectangles does not intersects, the method returns none.

Source

pub fn intersects(&self, other: TileRect) -> bool

Checks if the rectangle intersects with some other rectangle.

Source

pub fn translate(&self, translation: Vector2<i32>) -> Self

Offsets the given rectangle and returns a new rectangle.

Source

pub fn extend_to_contain(&mut self, other: TileRect)

Extends the rectangle so it will contain the other rectangle.

Source

pub fn left_top_corner(&self) -> Vector2<i32>

Returns the top left corner of the rectangle.

Source

pub fn right_top_corner(&self) -> Vector2<i32>

Returns the top right corner of the rectangle.

Source

pub fn right_bottom_corner(&self) -> Vector2<i32>

Returns the bottom right corner of the rectangle.

Source

pub fn left_bottom_corner(&self) -> Vector2<i32>

Returns the bottom left corner of the rectangle.

Source

pub fn w(&self) -> i32

Returns width of the rectangle.

Source

pub fn h(&self) -> i32

Returns height of the rectangle.

Source

pub fn x(&self) -> i32

Returns horizontal position of the rectangle.

Source

pub fn y(&self) -> i32

Returns vertical position of the rectangle.

Trait Implementations§

Source§

impl Clone for TileRect

Source§

fn clone(&self) -> TileRect

Returns a duplicate 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 TileRect

Source§

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

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

impl From<TileRect> for OptionTileRect

Source§

fn from(source: TileRect) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for TileRect

Source§

type Item = Matrix<i32, Const<2>, Const<1>, ArrayStorage<i32, 2, 1>>

The type of the elements being iterated over.
Source§

type IntoIter = RectIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for TileRect

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for TileRect

Source§

impl Eq for TileRect

Source§

impl StructuralPartialEq for TileRect

Auto Trait Implementations§

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> AsyncTaskResult for T
where T: Any + Send + 'static,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts self reference as a reference to Any. Could be used to downcast a trait object to a particular type.
Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FieldValue for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MessageData for T
where T: 'static + Debug + PartialEq + Any + Send + Clone,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self as Any reference.
Source§

fn compare(&self, other: &(dyn MessageData + 'static)) -> bool

Compares this message data with some other.
Source§

fn clone_box(&self) -> Box<dyn MessageData>

Clones self as boxed value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ScriptMessagePayload for T
where T: 'static + Send + Debug,

Source§

fn as_any_ref(&self) -> &(dyn Any + 'static)

Returns self as &dyn Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns self as &dyn Any
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ResourceLoadError for T
where T: 'static + Debug + Send + Sync,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,